Linux虚拟主机设置301重定向的2种简单方法

SEO技巧2,2682

1、打开虚拟主机的管理面板(控制面板),在域名301重定向中进行设置。

 文章源自SEO视频网-https://www.seoshipin.cn/seojiqiao/88.html

2、如果虚拟主机管理面板没有301重定向的话,那么可以通过.htaccess文件进行设置。文章源自SEO视频网-https://www.seoshipin.cn/seojiqiao/88.html

在本地新建一个文本文件,最好用的专业的编辑器软件如EditPlus 将代码粘入文章源自SEO视频网-https://www.seoshipin.cn/seojiqiao/88.html

  1. RewriteEngine On
  2. RewriteCond %{HTTP_HOST} !^seoshipin.cn$ [NC]
  3. RewriteRule ^(.*)$ http://www.seoshipin.cn/$1 [R=301,L]

说明:上述规则是将顶级域名重定向到www域名。文章源自SEO视频网-https://www.seoshipin.cn/seojiqiao/88.html

 文章源自SEO视频网-https://www.seoshipin.cn/seojiqiao/88.html

如果仅想将绑定在站点上某个域名(如:www.123.com)重定向到www.seoshipin.cn,规则如下:文章源自SEO视频网-https://www.seoshipin.cn/seojiqiao/88.html

RewriteCond %{HTTP_HOST} ^www.123.com$ [NC]文章源自SEO视频网-https://www.seoshipin.cn/seojiqiao/88.html

RewriteRule ^(.*)$ http://www.seoshipin.cn/$1 [R=301,L]文章源自SEO视频网-https://www.seoshipin.cn/seojiqiao/88.html

 文章源自SEO视频网-https://www.seoshipin.cn/seojiqiao/88.html

如果有多种需求,如abc.com跳转到www.abc.com,qwe.com跳转到www.qwe.com,规则如下:文章源自SEO视频网-https://www.seoshipin.cn/seojiqiao/88.html

  1. RewriteEngine On
  2. RewriteCond %{HTTP_HOST} ^abc.com$ [NC]
  3. RewriteRule ^(.*)$ http://www.abc.com/$1 [R=301,L]
  4. RewriteCond %{HTTP_HOST} ^qwe.com$ [NC]
  5. RewriteRule ^(.*)$ http://www.qwe.com/$1 [R=301,L]

 

最后,根据自己的需要进行添加修改,然后上传到虚拟主机的网站根目录,改名为.htaccess即可。

 
  • 本文由 潮涌SEO 发表于 2017年4月8日 02:30:11
  • 转载请务必保留本文链接:https://www.seoshipin.cn/seojiqiao/88.html