www.xyz.com和xyz.com之间的区别以及如何重定向.htaccess



我有一个网站,正在使用Google网站管理员工具。我在该工具中为该网站创建了两次设置:一次作为www.xyz.com,一次作为xyz.com。深入了解细节后,两者的统计数据有所不同。

我想继续使用www.xyz.com。我如何让每个人都转到xyz.com并重定向到www.xyzcom?这会损害我在谷歌的排名或索引吗?

问候,

很抱歉,如果问题很简单:(

使用htaccess,我使用以下内容进行强制www

RewriteEngine on 
RewriteCond %{HTTP_HOST} !^www 
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [L,R=301] 

尽管你可能最好做以下,如果它是为了SEO目的

RewriteEngine on 
RewriteCond %{HTTP_HOST} !^www 
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [L,R=301] 
RewriteCond %{THE_REQUEST} ^.*/index.php 
RewriteRule ^(.*)index.php$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.htm
RewriteRule ^(.*)index.htm$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/home.htm
RewriteRule ^(.*)home.htm$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/home.html
RewriteRule ^(.*)home.html$ http://%{HTTP_HOST}/$1 [R=301,L]

因为这也会删除url的任何索引或主页部分。

在网站管理员工具的设置中,您还可以选择始终使用www,这将把两个域的数据合并到一个www域下(尽管您可以在GWMT中看到www和非www(

使用首选域,此处有更多说明:

http://support.google.com/webmasters/bin/answer.py?hl=en&答案=44231

指定首选域:

On the Webmaster Tools Home page, click the site you want.
Under Site configuration, click Settings.
In the Preferred domain section, select the option you want.

您也可以使用301重定向:http://support.google.com/webmasters/bin/answer.py?hl=en&答案=93633

最新更新