mod_rewrite and .htaccess on VirtualHosts

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
nils73
Power Poster
Power Poster
Posts: 520
Joined: Wed Sep 08, 2004 3:32 pm

mod_rewrite and .htaccess on VirtualHosts

Post 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
jelle

Re: mod_rewrite and .htaccess on VirtualHosts

Post 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.
nils73
Power Poster
Power Poster
Posts: 520
Joined: Wed Sep 08, 2004 3:32 pm

Re: mod_rewrite and .htaccess on VirtualHosts

Post 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
Post Reply

Return to “Tips and Tricks”