Forum Moderators: phranque

Message Too Old, No Replies

How to redirect index.html to index.shtml

         

newbies

9:03 am on Oct 29, 2004 (gmt 0)

10+ Year Member



Recently I changed my home page from index.html to index.shtml and some inbound links still point to index.html. I try add a 301 redirect to .htaccess file but could not make it right.

I added this line:
Redirect 301 /index.html [mydomain.com...]

If I enter my site by typing in the address bar [mydomain.com...] I can load the home page, but if I type [mydomain.com...] only, there will be a loop and the home page will never get loaded in my browser.

What is the right way of doing this?

Thank you for your help.

jdMorgan

7:25 pm on Oct 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You will need to override the default server settings, which probably set index.html as your default index page, thus creating the loop.

Try this:


DirectoryIndex index.shtml
Redirect 301 /index.html http://www.mydomain.co[b]m/[/b]

See Apache mod_dir [httpd.apache.org] for more details.

Jim

newbies

7:49 pm on Oct 29, 2004 (gmt 0)

10+ Year Member



Thanks Jim,

But only the home page uses index.shtml, all other dirs use index.html, will that be a problem if I use your command?

jdMorgan

8:20 pm on Oct 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, it would be, but you can try one of two things:

  • Change the DirectoryIndex directive to read:
    DirectoryIndex index.shtml index.html 

    -or-
  • Put an .htaccess file in each subdirectory that uses index.html containing
     DirectoryIndex index.html 

    Jim

  •