Forum Moderators: phranque

Message Too Old, No Replies

Rewrite won't work with virtual hosts

Problems getting rewrite_mod to work on server with multiple domains

         

gedankenspiel

10:09 pm on Nov 21, 2005 (gmt 0)



In a recent effort to make my site search engine friendly, I decided to use the apache rewrite_mod module. On my test server which is identical to our production server (with the exception of virtual hosts), I was able to get the following rewrite rules to work flawlessly:

RewriteEngine On
RewriteRule ^/([a-z0-9]+)/?$ /index.cfm?event=$1 [PT,NC,L]
RewriteRule ^/([a-z0-9-]+)/([a-z0-9-]+)/?$ /index.cfm?event=$1.$2 [PT,NC,L]
RewriteRule ^/([a-z0-9-]+)/([a-z0-9-]+)/([a-z0-9-]+)/?$ /index.cfm?event=$1.$2&sortorder=$3 [PT,NC,L]
RewriteRule ^/([a-z0-9-]+)/([a-z0-9-]+)/([a-z0-9-]+)/([a-z0-9-]+)/([a-z0-9-]+)/([a-z0-9-]+)?$ /index.cfm?even

However, once I insert the same code into the production Apache config file, nothing happens - no errors, the site continues to behave the same way. When I test my SES URL's, I simply get "The file could not be found".

The only major difference between the two servers is that the production version has a list of virtualhost directives at the bottom:

<VirtualHost 38.113.18.17:80>
ServerName library.site.com
DocumentRoot c:/InetPub/wwwroot/mylibrary
ServerAdmin admin@site.com
</VirtualHost>

I have also attempted to put the rewrite code simply into a .htaccess file - but nothing happens. I am not even sure if the htaccess file gets called at all.

I have set AllowOverride All wherever I found a <Directory> tag.

Any help is much much appreciated. I have been working on this for two days straight.

Thanks
K

jdMorgan

3:03 am on Nov 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll need AllowOveride FileInfo Options at minimum, and you'll need to enable Options FollowSymLinks or Options SymLinksIfOwnerMatch to enable mod_rewrite. You should also check to make sure that mod_rewrite is available and loaded on your server.

I'd suggest testing with a very simple mod_rewrite rule until you're sure that mod_rewrite is actually running, something like:


RewriteRule ^foo\.html$ http://www.example.com/your_home_page_here.html [R=301,L]

Then request foo.html from your server, and it should serve your home page instead. Once that works, then you can get into the more-complex-code testing.

Jim