Page 1 of 1

mod_rewrite and .htaccess on VirtualHosts

Posted: Thu Mar 23, 2006 5:03 pm
by nils73
I had a problem with mod_rewrite and VirtualHosts. It did not work and so I had to dig into Apache logfile and with a little help by an admin-friend of mine I finally figured out what to do:

Code: Select all

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^(.+)\.html$ /index.php?page=$1 [QSA]
I put a simple "/ in front of index.php and that was it. Maybe others find this tip useful since VirtualHosts are quite common.

Regards,
Nils

Re: mod_rewrite and .htaccess on VirtualHosts

Posted: Thu Mar 23, 2006 8:55 pm
by jelle
This may be very usefull, but can you elaborate a bit on what went wrong exactly and how this / changes that? now it's a bit of a loose answer without a question.

Re: mod_rewrite and .htaccess on VirtualHosts

Posted: Fri Mar 24, 2006 8:59 am
by nils73
I am not very familiar with mod_rewrite but in my error log I found a string where I had /path/to/site/path/to/site instead of only /path/to/site --- and then a friend of mine told me that it would be better to have /index.php instead of index.php, because then the URL would be relative ...

While telling me that he also mentioned that it should be !f rather than !d but it wouldn't have much effect he explained. Well ... mod_rewrite is cool but pretty difficult either.

Regards,
Nils