Forum Moderators: phranque

Message Too Old, No Replies

Redirect /index.html to /

         

ebobnar

5:47 am on Jun 24, 2005 (gmt 0)

10+ Year Member



Hi,

I'd like to prevent search engines from indexing my homepage as http://www.example.com/index.html.

To do so, I'd like to redirect

http://www.example.com/index.html

to

http://www.example.com/

Of course, any attempt to do so results in a server loop. Is this redirect possible?

jdmorgan posted on this before [webmasterworld.com], and I'm wondering if he could elaborate on his explanation, since it doesn't work for me.

> Any ill effects if I use this?
> Redirect 301 /index.html http*//www.example.com/

Well, you could put your server into a loop at worst. If index.html is requested, you'll redirect from index.html to "/". A 301 response will be sent back to the client saying "request that from '/'." So, the client will then request "/", and then DirectoryIndex (Apache mod_dir) kicks in and redirects that to index.html. IF there are any subrequests associated with fetching index.html, then the Redirect 301 (mod_alias) will kick in again, and the whole process starts over. Then you've got a loop.

You can get around this by renaming index.html to anything else -- like home.html, default.html, or index.htm - It just has to be different from the original existing filename. If you stray from the standard "home page" names defined in your server configuration, you may have to add a DirectoryIndex directive:

DirectoryIndex index.html index.htm whatever.html

This defines the possible index page names, and the order to check for them. Make sure the filename you are trying to redirect from is not in that list, and that the file you want served in response to requests for "/" *is* in the list.

Thanks

[edited by: txbakers at 1:02 pm (utc) on June 24, 2005]
[edit reason] examplified URL - "site" is a real domain! [/edit]