[TriLUG] Apache mod-rewrite question

Rick DeNatale rick.denatale at gmail.com
Thu Jun 16 23:55:12 EDT 2005


I want to selectively rewrite null uri's in Apache based in ONE of my
name based virtual hosts.

I've tried a few variations of this:

<VirtualHost *>
        ServerAdmin webmaster at denhaven2.homeip.net
        ServerName www.mercuryspacecraft.com
        DocumentRoot /var/www/html
        RewriteEngine on

        RewriteRule index.html$ /wiki/Main_Page [R]

        # Rewrite any article as wiki/index.php/article and stop
        RewriteRule ^/wiki/?(.*)$ /w/index.php?title=$1 [L,QSA]

</VirtualHost>

The second RewriteRule works fine, it's the first one I'm having trouble with.
I've also tried

      RewriteRule ^$ /wiki/Main_Page [R]

The desired effect is for http://www.mercuryspacecraft.com
or http://www.mercuryspacecraft.com/ to get rewritten (and displayed
to the client) as http://www.mercuryspacecraft.com/wiki/Main_Page
which in turn gets rewritten internally to
http://www.mercuryspacecraft.com/w/index.php?title=Main_Page

If I browse http://www.mercuryspacecraft.com/Main_Page, the second
rewrite works fine, but the empty uri cases serve up
/var/www/html/index.html  which I DON'T want for this server name.

In fact I'm not sure now just how I'm getting http://anyserver/ to
resolve to index.html

mod_rewrite makes my head spin every time I play with it, or should I
say it plays with me.



More information about the TriLUG mailing list