Page 1 of 1

URL Rewriting without .htaccess?

Posted: Tue May 29, 2007 10:24 pm
by sv6
Sorry if this has been answered before - just couldn't find a clear answer.  I am on version 1.0.6

Is it possible to have URL Rewriting (mod_rewrite) without using .htaccess?  I believe that with Apache you can have the equivalent rules in httpd.conf, but I wasn't sure if CMSMS itself requires there be an .htaccess file.

Thanks in advance.

Re: URL Rewriting without .htaccess?

Posted: Wed May 30, 2007 1:22 am
by calguy1000
if you have access to httpd.conf then you have 'god' access over the web server.  the .htaccess stuff only works if the httpd.conf stuff (apache only of course) says that the specific directory can allow overrides of any type.

so, if you have access to httpd.conf, you need to do a heckuva lot of reading on the apache configuration files, it's syntax, and the permutations and combinations of all of the variables within that.

the .htaccess file allows only a limited subset of that, and only if the httpd.conf allows it to.

Re: URL Rewriting without .htaccess?

Posted: Wed May 30, 2007 3:21 pm
by sv6
Thanks for the reply.

The issue I have is that my client's hosting provider does not allow .htaccess at all.  However, they are willing to help me with getting rewrite rules in (in http.conf) - as long as it does not contain any filesystem calls.  Unfortunately, the following rules (in documentation) does contain filesystem calls (the the -f and -d parts):

Code: Select all

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]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
Looking around on these forums, folks have posted that if those two lines are taken out, it will still work.  So the final rules would be:

Code: Select all

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
Unfortunely, there's no way for me to test this.  Just wanted to see if others have had success with this (before I go around and around with the hosting providers support folks).  Thanks.

Re: URL Rewriting without .htaccess?

Posted: Wed May 30, 2007 3:54 pm
by Pierre M.
Hello,
sv6 wrote: folks have posted that if those two lines are taken out, it will still work.
yes, I think those two lines allow to shadow your dynamic site behind static content : they give priority to the static content that could have same/similar URLs. So if you have not such static content, "it will still work" but back up is your friend.
Pierre M.

Re: URL Rewriting without .htaccess?

Posted: Wed May 30, 2007 10:12 pm
by sv6
Thanks for the insight.  That's very helpful.