WWW重定向到非WWW,还是其他方式? [英] Redirect WWW to non WWW, or the other way around?

查看:171
本文介绍了WWW重定向到非WWW,还是其他方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚跑在我的网站SEO的审计和收到此消息...


  

要确保www.mysite.co.uk和myside.co.uk不是在运行
  平行。


  
  

重定向从非$ P $请求主机pferred是非常重要的
  因为搜索引擎的网址考虑使用和不使用www的两个
  不同的网站。


  
  

一旦你的preferred域设置,使用301重定向所有流量
  你非preferred域。


现在我的网站,可以使用两种WWW。无论是否包含www。那么这是否意味着我的网站上并行运行?

如果让我怎么解决这个问题?并应我指出我的非WWW到WWW或其他方式?

即时通讯使用的是Linux / Apache服务器上的PHP。


解决方案

  

现在我的网站,可以使用两种WWW。无论是否包含www。那么,这是否
  意思是并行运行我的网站?


pretty得多。并行运行是指访问者(人或搜索引擎机器人),可以用URL的www和非www版本访问相同的内容。

建议的做法是有活跃的两个主机名,但重定向pferred主机名到$ P $非$ P $的所有流量pferred酮使用301重定向。


  

如果让我怎么解决这个问题?


对于Apache,将在位于wwwroot目录的的.htaccess 文件中的这些规则:

  #########################
#重定向没有WWW到www
#########################RewriteEngine叙述在
的RewriteCond%{HTTP_HOST} ^(?! WWW \\)(+)[NC]
(。*)^重写规则的http://www.%1/$1 [R = 301,NE,L]

- 或 -

  #########################
#重定向到WWW无WWW
#########################RewriteEngine叙述在
的RewriteCond%{HTTP_HOST} ^ WWW \\。(+)[NC]
(。*)^重写规则的http://%1 / $ 1 [R = 301,NE,L]


  

和应i点我非WWW到WWW或其他方式?


有没有明确的答案;两者各有利弊。请参见是WWW 的理解为什么有一个WWW网址是好的,而其竞争对手的No WWW 的这只是说的WWW。是pcated德$ p $。的没有解释。

Ive just ran an seo audit on my site and received this message...

Be sure that www.mysite.co.uk and myside.co.uk are not running in parallel.

Redirecting requests from a non-preferred hostname is important because search engines consider URLs with and without "www" as two different websites.

Once your preferred domain is set, use a 301 redirect for all traffic to your non-preferred domain.

Now my website works with both www. and without the www. so does this mean my sites running in parallel?

If so how do i address this? and shall i point my non www to the www or the other way around?

Im using PHP on a linux/apache server.

解决方案

Now my website works with both www. and without the www. so does this mean my sites running in parallel?

Pretty much. Running in parallel means that a visitor (human or search engine robot) can access same content with www and non-www version of the URL.

The recommended practice is to have both hostnames active but redirect all traffic of the non-preferred hostname to the preferred one using 301 redirect.

If so how do i address this?

For Apache, place these rules in the .htaccess file located in the wwwroot directory:

#########################
# redirect no-www to www
#########################

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?!www\.)(.+) [NC]
RewriteRule ^(.*) http://www.%1/$1 [R=301,NE,L]

-- or --

#########################
# redirect www to no-www
#########################

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^(.*) http://%1/$1 [R=301,NE,L]

and shall i point my non www to the www or the other way around?

There is no definite answer; both have their pros and cons. See Yes WWW to understand why having a www URL is good, and its competitor No WWW which simply says "www. is deprecated." without an explanation.

这篇关于WWW重定向到非WWW,还是其他方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆