Hi My existing index page is index.html but I would like to create a 301 redirect so that when people either land on the root of the domain e.g. mydomain.com/ the automatically go to index.php. However, despite using the code below people are still going to index.html rather than index.php I would be very grateful if someone could help me out please - Thanks My .htaccess code at present looks like this RewriteEngine on RewriteRule ^/$ index.php [R=301,L] RewriteRule ^index\.html$ index.php [R=301,L]
Nope - none of those worked. I use apache so the 301 is different all of my 301 rewrites work except the one for the root directory i.e. / should automatically go to index.php
Try this code: RewriteEngine on RewriteRule ^$ \/index.php [R=301,L] RewriteRule ^index\.html$ \/index.php [R=301,L]
Might work...? Options +FollowSymLinks RewriteEngine on RewriteBase / RewriteRule ^index\.php index.html [L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/ RewriteRule ^index\.html /index.php [R=301,L] Code (markup):
Thanks I'll check these out. I may have found an alternative reason as to why it is not working. The domain is hosted used Apache on an IIS server - so perhaps the default page just needs to be changed to index.php.... we shall see
if index.html is the same as index.php, then you can delete the index.html file and users will be redirected automatically to index.php, no need to modify your .htaccess file.
Anyway, if the index.html page is pretty old, it is a good idea to leave the redirection from index.html to index.php. Because some visitors may have bookmarked this page.