本文介绍了追加的index.html到根目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的新网站的一个问题。 (www.example.com)

I have a problem with my new site. (www.example.com)

基本上,当我看着我的谷歌分析网页,它认为mysite的/ index.html,然后mysite的/是两个不同的网页。这是有问题的,主要的搜索引擎优化的原因。

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.

有没有办法来追加两个或弄根自动重定向到mysite的/ index.html的?我想你大概可与301重定向或通过修改.htaccess文件做到这一点。

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.

我的主机是通过的iPage的方式。

My host is iPage by the way.

感谢

推荐答案

您可以通过添加以下code到位于根.htaccess文件来完成此一Apacher服务器上:

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]

这需要任何要求,只是'/',并将其改写为/index.html。我个人觉得,追加的index.html是比替代丑陋,所以这里是一些的.htaccess code的删除的index.html从网址:

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]

这篇关于追加的index.html到根目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 21:09