URL Rewriting without .htaccess?

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
sv6
New Member
New Member
Posts: 5
Joined: Mon Mar 26, 2007 3:24 pm

URL Rewriting without .htaccess?

Post 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.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: URL Rewriting without .htaccess?

Post 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.
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.
sv6
New Member
New Member
Posts: 5
Joined: Mon Mar 26, 2007 3:24 pm

Re: URL Rewriting without .htaccess?

Post 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.
Pierre M.

Re: URL Rewriting without .htaccess?

Post 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.
sv6
New Member
New Member
Posts: 5
Joined: Mon Mar 26, 2007 3:24 pm

Re: URL Rewriting without .htaccess?

Post by sv6 »

Thanks for the insight.  That's very helpful.
Post Reply

Return to “CMSMS Core”