Apache 2中重定向domain.com到www.domain.com [英] redirecting domain.com to www.domain.com in Apache 2
问题描述
我听到搜索引擎识别domain.com和www.domain.com为不同的地址。
所以重定向domain.com到www.domain.com将是更好的搜索引擎优化
I heard search engines recognize domain.com and www.domain.com as different addresses. So redirecting domain.com to www.domain.com would be better for SEO.
你会怎么做呢?
我访问的apache.conf
How would you do it? I have access to apache.conf
推荐答案
您可以把以下几行你的.htaccess
You can put following lines in you .htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
如果你想这只是搜索引擎优化的目的,那么你还可以在www.domain.com管理者工具的prefererred域。
If you want this only for SEO purpose then you can also make www.domain.com your prefererred domain in Webmasters Tools.
在谷歌网站管理员,你可以做
1.Goto https://www.google.com/webmasters/tools/settings ?
2.在站点配置>设置,您可以设置preferred域。
In Google webmaster you can do
1.Goto https://www.google.com/webmasters/tools/settings?
2. Under "site configurations > settings" you can set your preferred domain.
这篇关于Apache 2中重定向domain.com到www.domain.com的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!