cancel
Showing results for 
Search instead for 
Did you mean: 

CMS made simple mod_rewrite

suzyb
Grafter
Posts: 27
Registered: ‎19-09-2007

CMS made simple mod_rewrite

I have an htaccess file to rewrite CMSMS page urls to more friendly names.  However i am getting an error when I set the site up on my cgi web space.
This is my htaccess file.  Can anyone tell me what I am missing?
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
# 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}/
# 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]

Thanks
2 REPLIES 2
oliverb
Grafter
Posts: 606
Registered: ‎02-08-2007

Re: CMS made simple mod_rewrite

If the ccgi server is anything like the web server then you probably have problems with it reporting an overlong path and unexpected slashes. I had to write test rules that hard-redirected to a dummy page and dumped the variables into the URL, that way I could see what the variables contained and adjust the rule to compensate.
spraxyt
Resting Legend
Posts: 10,063
Thanks: 674
Fixes: 75
Registered: ‎06-04-2007

Re: CMS made simple mod_rewrite

Quote from: suzyb
Options +FollowSymLinks

The security model suEXEC on new ccgi does not allow that Options line so it needs to be removed. The server configuration sets the equivalent of that by default. I think the file should work without that.
However suEXEC uses ~username mapping and %{REQUEST_URI} contains /~username/rest_of_url. So /~username will appear in the browser address line when a trailing slash is added. You could use %{ENV:SCRIPT_URL} if you don't want /~username to appear.
David