mod_rewrite using virtual hosts

eDave

Joined: 2005-03-05
Posts: 1
Posted: Sat, 2005-03-05 22:15

Very simple hack for those who prefer not to use .htaccess files on their servers. Here's a modrewrite rule to use in a <virtualhost>

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !gallery_remote2.php
RewriteRule ^/gallery(.+)$ /gallery/main.php?g2_RewriteUrlGenerator=$1   [QSA]

I didn't really do much to the rules to get it working, short of removing the parts which don't work in <virtualhost> directives. (RewriteBase /gallery/, etc)

Note: You may need to modify the RewriteCond's for your setup.
i.e: on my server I had to put:

...
RewriteCond /path/to/docroot%{REQUEST_FILENAME} !-f
...

Also, for now you'll need to actually create the .htaccess file to get the mod_rewrite module to activate.

Seeing as this is my first post, I'd like to offer my sincere thanks to the dev team for creating such a fantastic product! :D

~eDave