如何统一域名提高权重(做301跳转)

2022-09-11 12:46:31 浏览数 (1)

www的其实算是2级域名了,我们可以把收录归到一个域名上面,做301跳转。

.htaccess

代码语言:javascript复制
#www 301跳转到非www
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L] 
#单独的http和https执行此操作
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L] 
#非www重定向到www (均为:http   https)
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

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

0 人点赞