Page 1 of 1

SOLVED - Pretty URLs and mod_rewrite = 404

Posted: Fri Nov 06, 2009 11:16 pm
by mjcp
I have a base installation of 1.6.6.  located in a sub folder www.domain.com/cms

I have set .httaccess as:

# Options +FollowSymLinks
RewriteEngine on
RewriteBase /cms/

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
# except for form POSTS
# RewriteCond %{REQUEST_URI} !/$
# RewriteCond %{REQUEST_URI} !\.
# RewriteCond %{REQUEST_METHOD} !POST$
# 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
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)(.html)?$ index.php?page=$1 [QSA]

I have set config.php:

$config['url_rewriting'] = 'mod_rewrite';
$config['page_extension'] = '.html';
$config['use_hierarchy'] = true;
$config['query_var'] = 'page';

I want to create URLs as: www.domain.com/cms/page_name.html

When I hover over a link I see the correct www.domain.com/cms/page_name.html
When I click a link I get an error 404

If I click the home icon, it works correctly and goes back to www.domain.com/cms

I have several earlier versions (1.5.4) of CMSMS running on the same host and Pretty URLs are working happily.

Any ideas?!?

Cheers,

Marc

Re: Pretty URLs and mod_rewrite = 404

Posted: Sat Nov 07, 2009 10:34 am
by alby
mjcp wrote: I have a base installation of 1.6.6.  located in a sub folder www.domain.com/cms

I have set .httaccess as:
Try with this .htaccess (source http://wiki.cmsmadesimple.org/index.php ... And_Tricks):
 Options +FollowSymLinks
 RewriteEngine on
 RewriteBase /cms

 # 301 Redirect all requests that don't contain a dot or trailing slash to
 # include a trailing slash
 # except for form POSTS
 # RewriteCond %{REQUEST_URI} !/$
 # RewriteCond %{REQUEST_URI} !\.
 # RewriteCond %{REQUEST_METHOD} !POST$
 # 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
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.+).htm$ index.php?page=$1 [QSA]
Alby

SOLVED - Re: Pretty URLs and mod_rewrite = 404

Posted: Sat Nov 07, 2009 11:59 am
by mjcp
Thanks,

I pasted your .htt version and changed .html to .htm in config.pho and it worked!  Have now changed both to .html and it's still going strong.

I think my errors were:

1.  In the RewriteBase I have /cms/  you had /cms  (no trailing / )
2.  You had RewriteRule ^(.+).htm$ index.php?page=$1 [QSA]
  I had RewriteRule ^(.+)(.html)?$ index.php?page=$1 [QSA]  (no "( )?"  around the .html  )

Many thanks!

Marc