Page 1 of 1

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

Posted: Tue Oct 24, 2006 4:08 pm
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>

Posted: Tue Oct 24, 2006 6:24 pm
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

Posted: Tue Oct 24, 2006 6:31 pm
by Luke
:D thanks a lot volka!