Append index.html to root directory

╄→尐↘猪︶ㄣ 提交于 2020-01-05 15:00:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!