追梦IDC,草根站长值得拥有的基础网络服务商!

首页 >  帮助中心 > 虚拟主机301跳转设置

虚拟主机301跳转设置

来源:原创 点击量(131) 发布时间:2015-04-30

Linux下301重定向设置

1.登陆后台,开启伪静态支持
2.将下面的代码复制到.htaccess文件中,保存。
(单个域名跳转)
RewriteEngine on
RewriteBase /
RewriteCond %{http_host} ^xxx.com [NC]
RewriteRule ^(.*)$ http://www.xxx.com/$1 [L,R=301]

多个域名跳转
RewriteEngine on
RewriteBase /
RewriteCond %{http_host} ^www.zmidc.net [NC]
RewriteRule ^(.*)$ http://www.zmidc.cn/$1 [L,R=301]
RewriteCond %{http_host} ^www.zmidc.com [NC]
RewriteRule ^(.*)$ http://www.zmidc.cn/$1 [L,R=301]

或者
RewriteCond %{http_host} ^www\.1\.com.* [OR]
RewriteCond %{http_host} ^1\.com.* [OR]
RewriteCond %{http_host} ^2\.com.*
RewriteRule ^(.*)$ http://www.2.com/$1 [L,R=301]

3.将.htaccesss文件上传至站点根目录下。


IIS 7 301 重定向代码 加到web.config里
<configuration>
<system.webServer>
<rewrite>
   <rules>
       <rule name="Enforce canonical hostname" stopProcessing="true">
           <match url="(.*)" />
           <conditions>
               <add input="{HTTP_HOST}" negate="true" pattern="^www.zmidc.com$" />
           </conditions>
           <action type="Redirect" url="http://www.zmidc.com/{R:1}" redirectType="Permanent" />
       </rule>
   </rules>
</rewrite>
       <defaultDocument>
           <files>
               <add value="index.asp" />
           </files>
       </defaultDocument>
</system.webServer>
</configuration>