Pretty URLS running .... but... one question!

General project discussion. NOT for help questions.
giggler
Forum Members
Forum Members
Posts: 197
Joined: Tue Oct 09, 2007 7:08 am

Re: Pretty URLS running .... but... one question!

Post by giggler »

Did you put anything else in htaccess? anything like:

Code: Select all

   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l

The url shows titlename, but I got "The requested URL was not found on this server."

There's also a

Code: Select all

f$mapped
on top of all the pages with the line commented out from misc.functions.php
Last edited by giggler on Wed Nov 28, 2007 7:09 am, edited 1 time in total.
raul.lnx
Forum Members
Forum Members
Posts: 26
Joined: Wed Jun 28, 2006 5:55 pm

Re: Pretty URLS running .... but... one question!

Post by raul.lnx »

This is part of my .htaccess

Code: Select all

###########################################################
#
# PARA EL MOD_REWRITE , HAY QUE TOCAR TB EL CONFIG DEL CMS

<Directory /var/www/snowzamora>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]

# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]

#ARCHIVO
RewriteRule ^archivo/categorias/(.+).html$ $1.html [NC,L]
RewriteRule ^archivo/2006/([a-z]*)_2006.html$ $1_2006.html [NC,L]
RewriteRule ^archivo/2007/([a-z]*)_2007.html$ $1_2007.html [NC,L]


#REESCRIBIMOS LAS NOTICIAS
RewriteRule ^noticias/([0-9]*)/(.+).html$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$1&cntnt01 [NC,L]

RewriteRule ^(.+).html$ index.php?page=$1 [QSA]

</Directory>



And config.php for CMS is:

Code: Select all

#------------
#URL Settings
#------------

$config['assume_mod_rewrite'] = true;
$config['page_extension'] = '.html';
$config['internal_pretty_urls'] = false;
$config['use_hierarchy'] = true;
$config['query_var'] = 'page';
macmukka
New Member
New Member
Posts: 6
Joined: Tue Oct 30, 2007 8:05 pm

Re: Pretty URLS running .... but... one question!

Post by macmukka »

Hi

Great tips on URLs - I have one problem, I can generate the URLS ok, but when I click on them I get a 404 error...if I use standard URLs eg.

http://URL/news/ID/RETURNID.html

everyhing is ok, but with SEO friendly it doesnt work my .htaccess is


Code: Select all

Options +FollowSymLinks
RewriteEngine on
RewriteBase /clients/punch/

# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]


# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.+).html %{REQUEST_URI}/ [R=301,L]


# rewrite for news
#RewriteRule ^([0-9]*).html$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$1 [NC,L]
RewriteRule ^([0-9]*)/([0-9]*).html$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$1&cntnt01returnid=$2 [NC,L]
RewriteRule ^(.+).html$ index.php?page=$1 [QSA]
site is running in sub directory on testing sever.

Any ideas - I am new to CMSMS and doing this as a favour to a friend!
raul.lnx
Forum Members
Forum Members
Posts: 26
Joined: Wed Jun 28, 2006 5:55 pm

Re: Pretty URLS running .... but... one question!

Post by raul.lnx »

Try this :

Code: Select all

<Directory /path_to/cms/> <---- ADD THIS LINE


Options +FollowSymLinks
RewriteEngine on
RewriteBase /clients/punch/

# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]


# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.+).html %{REQUEST_URI}/ [R=301,L]


# rewrite for news
#RewriteRule ^([0-9]*).html$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$1 [NC,L]
RewriteRule ^([0-9]*)/([0-9]*).html$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$1&cntnt01returnid=$2 [NC,L]
RewriteRule ^(.+).html$ index.php?page=$1 [QSA]

</Directory> <----- AND THIS

I have been testing your rewrite line:

RewriteRule ^([0-9]*)/([0-9]*).html$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$1&cntnt01returnid=$2 [NC,L]

And works perfect in my webpage ......

Look my latest post, and compare your config.php .....


PD: sorry i speak english a little bit ;)
zeretto

Re: Pretty URLS running .... but... one question!

Post by zeretto »

Hi,

I have the same problem of macmukka

The url is rewrite but when I click on the title news I get a 404 error,  ???

You have a solution  ;)
Kevin C
Forum Members
Forum Members
Posts: 10
Joined: Tue Dec 11, 2007 4:48 pm

Re: Pretty URLS running .... but... one question!

Post by Kevin C »

This worked fine for me - but I'd like to get the title of the article in both the page title and the URL.  I had the news title in the page title following the modifications described here - http://forum.cmsmadesimple.org/index.ph ... 646.0.html

But this approach depends on using a detail page, and the change in action.default.php got rid of the detailpage parameter.

Is there any way to make these 2 approaches work together?
giggler
Forum Members
Forum Members
Posts: 197
Joined: Tue Oct 09, 2007 7:08 am

Re: Pretty URLS running .... but... one question!

Post by giggler »

Kevin C,

Did you get this to work on 1.2.3?
macmukka
New Member
New Member
Posts: 6
Joined: Tue Oct 30, 2007 8:05 pm

Re: Pretty URLS running .... but... one question!

Post by macmukka »

I've been away for a bit but am now trying to get Pretty URLs resoved in 1.2.3.

I will explain what has been done so it helps people who might visit this later. Think things got a bit confusing ;-)

Changes to action.default.php

Code: Select all

//$prettyurl = 'news/'.$row['news_id'].'/'.($detailpage!=''?$detailpage:$returnid);  <--------- commented out
	
$row['news_title'] = str_replace(' ', '_', $row['news_title']); // <------- added for pretty URL hack
$prettyurl = 'news/'.$row['news_id'].'/'.$row['news_title'];   // <------- added for pretty URL hack


Code: Select all

#CreateLink($id, $action, $returnid='', $contents='', $params=array(), $warn_message='', $onlyhref=false, $inline=false, $addttext='', $targetcontentonly=false, $prettyurl='')

$row['news_title'] = str_replace('_', ' ', $row['news_title']);  //   <-------- added this line eveything else as 1.2.3

    $onerow->link = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, '', $sendtodetail,'', true, false, '', true, $prettyurl);
  
$onerow->titlelink = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, $row['news_title'], $sendtodetail, '', false, false, '', true, $prettyurl); 
    
	$onerow->morelink = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, $moretext, $sendtodetail, '', false, false, '', true, $prettyurl);
    
	$onerow->moreurl = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, $moretext, $sendtodetail, '', true, false, '', true, $prettyurl);
config settings

Code: Select all

#Show mod_rewrite URLs in the menu? You must enable 'use_hierarchy' for this to work for modules
$config['assume_mod_rewrite'] = true;

#Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '.html';

#If you don't use mod_rewrite, then would you like to use the built-in
#pretty url mechanism?  This will not work with IIS and the {metadata} tag
#should be in all of your templates before enabling.
$config['internal_pretty_urls'] = false;

#If you're using the internal pretty url mechanism or mod_rewrite, would you like to
#show urls in their hierarchy?  (ex. http://www.mysite.com/parent/parent/childpage)
$config['use_hierarchy'] = true;

#If using none of the above options, what should we be using for the query string
#variable?  (ex. http://www.mysite.com/index.php?page=somecontent)
$config['query_var'] = 'page';


.htaccess now looks like this:-

Code: Select all

Options +FollowSymLinks
RewriteEngine on
RewriteBase /subfolder/

# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.+).html %{REQUEST_URI}/ [R=301,L]

# rewrite for news
#RewriteRule ^([0-9]*).html$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$1 [NC,L]
RewriteRule ^([0-9]*)/([0-9]*).html$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$1&cntnt01returnid=$2 [NC,L]
RewriteRule ^(.+).html$ index.php?page=$1 [QSA]
The links are being generated as

news/id/title_of_the_story.html

which is great, but I cannot get them to work! I get a 404 error.

I am using a localhost xampp install for testing purposes on windows.

I tried to use the .htaccess changes but that didnt work.

apache log reports:

[Wed Jan 16 10:39:51 2008] [warn] RewriteCond: NoCase option for non-regex pattern '-d' is not supported and will be ignored.

I have tried countless combinations - does anyone have any ideas?

Thanks -
giggler
Forum Members
Forum Members
Posts: 197
Joined: Tue Oct 09, 2007 7:08 am

Re: Pretty URLS running .... but... one question!

Post by giggler »

yeah, I got the url link to look that way, but the page doesn't work either just like yours. Is it just impossible to do? To me, it's actually important to have this...
macmukka
New Member
New Member
Posts: 6
Joined: Tue Oct 30, 2007 8:05 pm

Re: Pretty URLS running .... but... one question!

Post by macmukka »

I agree giggler...thinking of going elsewhere as it's something my client wants.

I've never played with wordpress, but am thinking about it...

somebody stop me!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Pretty URLS running .... but... one question!

Post by calguy1000 »

News URLS containing the article-title won't currently work without some not-so-minor code changes.

This is because:
  a) There's no route defined that tells the system how to route that url to the news module, and how
      to identify the various parts of it.
  b) There's no way to guarantee the uniqueness of the article-title, or that the title doesn't contain
      bad characters.  some kind of article aliasing mechanism would need to be added to the news module
      The news module currrently will allow you to enter the same article title twice.... hence the use of
      the article id everywhere
  c) We would need to add default preferences for the news page to use, the detail template (this is done)
      and probably a few other things, as there's no way to specify them on a pretty url.
 
Are you trying to use the News module for something other than news articles?
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
giggler
Forum Members
Forum Members
Posts: 197
Joined: Tue Oct 09, 2007 7:08 am

Re: Pretty URLS running .... but... one question!

Post by giggler »

You can use wordpress with cmsms. It's not seamless integration since you can't have the login synced, but you can make it look like it's seamless if you're the only one posting to it or only have users use the blog to post things, but keeping the cmsms part out from multiple users:

http://forum.cmsmadesimple.org/index.ph ... 778.0.html
(I just got it to use the blog post and truncate it so it's short and don't need to enter excerpt. PM me if you want the updated UDT)

Though I do prefer using news/blog module from cmsms since it's easy to install and you don't have to do another install for WP and having to mess with the css of WP to make it look consistent. Once news or blog module can have article-title.html, then it'll be much better...
macmukka
New Member
New Member
Posts: 6
Joined: Tue Oct 30, 2007 8:05 pm

Re: Pretty URLS running .... but... one question!

Post by macmukka »

a) I had thought this as I was changing things in the code. ;-) blind hope led me this far

b) I could probably handle writing an article aliasing mechanism. But I take you point about the duplicates. Guess a look up would be needed to check

c) true

I'm not trying to use the news module for anything other than news  - wp was just at the front of mind

My client is a PR company that had a site built by someone else and I am working on the pieces. As a PR company they are well aware of the value of news articles for rankings and really want to make something of their investment.

Thanks for coming back on this one calguy.

one last thought - If I amalgamated methods -  to produce a URL like so :-

www.site.com/news/1/2/this_is_an_article_title.html

where

1 = ID
2 = RETURNID

then I guess I could write a rewrite in htaccess to send that to the right place?


giggle- just seen your post. I am going to have a look at WP out of curiousity, but I think cmsms it prob the best route.....
giggler
Forum Members
Forum Members
Posts: 197
Joined: Tue Oct 09, 2007 7:08 am

Re: Pretty URLS running .... but... one question!

Post by giggler »

I've just updated the WP with CMSMS:

http://forum.cmsmadesimple.org/index.ph ... 778.0.html

Right now, the other reason for using WP with CMSMS is because WP already has the built in capability to notify search engines that there is a new post. This is actually very useful. I have blogs that comes up on the first page along with other actually local news sites for time sensitive event/things. Also the more you update, the better..if your intention is for SEO.
fritzfs
New Member
New Member
Posts: 8
Joined: Thu Feb 07, 2008 3:39 pm

Re: Pretty URLS running .... but... one question!

Post by fritzfs »

Hello guys,
here's the full solution for latest CMSms (1.2.3).

Edit file modules/News/action.default.php at line 312 and replace with this:

Code: Select all

$prettyurl = 'news/'.str_replace(' ', '-', $onerow->title).'/'.$row['news_id'].'/'.($detailpage!=''?$detailpage:$returnid);
Edit your .htaccess file and set like this:

Code: Select all

Options +FollowSymLinks
RewriteEngine on

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]

# News
RewriteRule ^news/([A-Za-z0-9-]+)/([0-9]+)/([0-9]+)/?$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$2&cntnt01returnid=$3 [L]

# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA
Edit your config.php, if should be like this:

Code: Select all

$config['assume_mod_rewrite'] = true;
$config['page_extension'] = '/';
$config['internal_pretty_urls'] = false;
$config['use_hierarchy'] = true;
$config['query_var'] = 'page';
After this changes URL for News will be :
www.domain.com/news/my-title-in-news/01/02/
01 - news id
02 - return id

Enjoy.
Post Reply

Return to “General Discussion”