不同网站服务器网页301重定向设置

文章类型:常见问题    发表2014-10-10   文章编辑:怒熊网络 · 一站式互联网+技术服务商!   阅读:338

第一种情况,windows系统的服务器或者vps

IIS下301设置
Internet信息服务管理器 -> 虚拟目录 -> 重定向到URL,输入需要转向的目标URL,并选择'资源的永久重定向'。

第二种情况,Linux的主机。


做整站301跳转,只需要修改文件httpd.conf或者.htaccess文件保存就可以了:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^xxxx.com [NC]

RewriteRule ^(.*)$ http://www.xxxx.com/$1 [L,R=301]

第三种情况,虚拟主机如何实现

虚拟主机可以利用httpd.ini文件为网站设置301永久重定向

1、网站服务器是IIS,在httpd.ini文件开始处加入以下规则:
RewriteCond Host: ^xxxx.com$
RewriteRule (.*) http://www.xxxx.com$1 [I,RP]

如果不存在httpd.ini,可以新建一个,添加如下代码:

[ISAPI_Rewrite]

# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
RewriteCond Host: ^xxxx.com$
RewriteRule (.*) http://www.xxxx.com$1 [I,RP]

2、若网站服务器是Apache,新建.htaccess文件,输入下列内容(需要开启mod_rewrite)

在.htaccess文件开始处加入一下规则

RewriteCond %{http_host} ^xxxx.com [NC]
RewriteRule ^(.*)$ http://www.xxxx.com/$1 [R=301,L]

附、httpd.ini多域名301跳转代码
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
RewriteCond Host: ^xxxx2.com$
RewriteRule (.*) http://www.xxxx2.com$1 [I,RP]
RewriteCond Host: ^www.xxxx2.com$
RewriteRule (.*) http://www.xxxx1.com$1 [I,RP]
RewriteCond Host: ^xxxx1.com$
RewriteRule (.*) http://www.xxxx1.com$1 [I,RP]

希望能帮到有困难的人~