Simple mod_rewrite


#1

I’ve got a site on DH that’s been using index.html as it’s homepage for some time now. I’d like to change it over to use index.php and still allow people who have bookmarked the index.html page to have the site automatically load the new index.php homepage. I’d rather not use the HTML redirect technique.

I’ve been trying to get mod_rewrite to work and have tried the example (and various permutations) of what I found on the DH wiki: http://wiki.dreamhost.com/Mod_rewrite

What I have found is that if I include the “Options +FollowSymLinks” line that the site comes up “500 Internal Error”.

If the .htaccess file contains just this:

RewriteEngine On
RewriteRule ^index.html$ /index.php

Then I just get the old index.html page. I suspect it’s something simple but I can’t seem to figure this one out.


#2

Using a .htaccess 301 will preserve any search engine rankings :wink:

redirect 301 /index.html http://www.domain.com/index.php

Maximum Cash Discount on any plan with MAXCASH


#3

Thanks for the input but when I put the .htaccess file that contains this:

RewriteEngine On
redirect 301 /index.html http://www.georgesmusicspace.com/index.php

Into the root directory for that site and I still get the old index.html home page coming up.


#4

The RewriteEngine On line is unnecessary.

Maximum Cash Discount on any plan with MAXCASH


#5

Not only unnecessary, but detrimental :wink:

It’s working perfectly now, thanks for the help.


#6

haha yes, a more apt term indeed.

Glad you have it sorted :wink:

Maximum Cash Discount on any plan with MAXCASH


#7

Just for curiosity, would the following provide the same results?

‘RewriteRule ^(.*).htm$ $1.php’

Regards.


#8

RewriteRule ^(.*).html$ $1.php [R=301,L]

But that would require the OP to convert all htm/html files to php.

If you want to mix & match you could probably allow html through the interpreter and keep the html extension on your php files.

AddType application/x-httpd-php htm html php
AddHandler application/x-httpd-php .htm .html

I’ve never tried this though :s

Maximum Cash Discount on any plan with MAXCASH