开发者

redirecting domain.com to www.domain.com in Apache 2

开发者 https://www.devze.com 2023-02-12 17:40 出处:网络
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.

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.

How would you do it? I have access to apache.conf


<VirtualHost *:80>
    ServerName domain.com
    Redirect permanent / http://www.domain.com/
</VirtualHost>


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]

If you want this only for SEO purpose then you can also make www.domain.com your prefererred domain in Webmasters Tools.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消