Can somebody make sure i wrote this correctly? (mod_rewrite)

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Can somebody make sure i wrote this correctly? (mod_rewrite)

Post by Luke »

I need to rewrite index.htm and index.html to index.php... and nothing else... this seems to work, but I just want to make sure there won't be any unexpected results...

Code: Select all

<IfModule mod_rewrite.c>
      RewriteEngine on
      RewriteRule ^index.htm|index.html$ index.php
</IfModule>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

index.htm|index.html
The dot stands for "any character" -> e.g. index2htm or index-htm match.
I'm not sure how the apache regular expressions are implemented but if possible you should avoid long branches, esp. when they are almost identical. I'd rather use

Code: Select all

RewriteRule ^index\.html?$ index.php
The ? makes the l optional
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

:D thanks a lot volka!
Post Reply