问题
I have a problem with my new site. (www.example.com)
Basically, when I look at my google analytics page, it considers mysite/index.html and mysite/ to be two different pages. This is problematic mainly for SEO reasons.
Is there a way to append the two or make the root automatically redirect to mysite/index.html? I figured you probably can do this with either a 301 redirect or by modifying the .htaccess file.
My host is iPage by the way.
Thanks
回答1:
You are able to accomplish this on an Apacher server by adding the following code to an .htaccess file located in the root:
RewriteEngine On
RewriteBase /
RewriteRule ^$ http://www.example.com/index.html [R=301,L]
This takes any requests to just '/' and rewrites them to '/index.html'. I, personally, feel that appending the index.html is uglier than the alternative, so here is some .htaccess code for removing index.html from the URL:
RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
RewriteRule ^index\.html$ http://www.example.com/ [R=301,L]
来源:https://stackoverflow.com/questions/10167755/append-index-html-to-root-directory