Forum Moderators: phranque

Message Too Old, No Replies

Help interpreting some confusing .htaccess behavior

         

coachm

1:49 am on May 6, 2011 (gmt 0)

10+ Year Member Top Contributors Of The Month



I had a file labelled index.html which was in the root directory and was the front page to my site.

I decided to make some changes, but wanted to leave that file as is, but create another file to replace it as the front page for the site.

I named this new file index.shtml

I then used directive in .htaccess as follows

DirectoryIndex index.shtml index.html index.htm index.php

my understanding being that if someone typed in [mysite.com...] it would display index.shtml instead of the original index.html

I also understood that for all directories it would first look for the index.shtml file, then the index.html then...

Here's the part I don't understand.

In my Google analytics, it's showing page visits to mydomain.com/subdirectory/index.shtml, even though that file doesn't exist.

That's happening in a number of subdirectories. So, the questions. Is there some explanation for the analytics showing this?

Is there an easier or other way to have both an index.html and an index.shtml in the same root directory?

Thanks

phranque

6:17 am on May 7, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



you might look in your server access logs for clues to explain the source of those non-canonical requests.

you should also implement a 301 redirect so that a request for a default directory index document is redirected to that directory root (the trailing slash url.)

i.e. the request for http://example.com/subdirectory/index.shtml should get a 301 status code and a Location: http://example.com/subdirectory/ HTTP Response header.