关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

虚拟主机如何做301

发布时间:2020-05-22 09:43:46

虚机主机如何做301?301转向又叫301重定向,或是301跳转,指的是用户或搜索引擎向网站服务器发出浏览请求时,服务器返回的HTTP数据流中头信息(header)中的状态码的一种,表示本网页永久性转移到另一个地址,从而确保流量能转移到最新版本的URL上。

以下是手工设置301的方法:

apache规则

在主机面板-文件管理,进入wwwroot,新建一个文件,命名为.htaccess文件,写入以下规则,保存即可

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{HTTP_HOST} ^xxxx1.com$ [NC]

RewriteCond %{HTTP_HOST} ^xxxx2.com$ [NC]

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

</IfModule>

实现的效果是xxxx.com访问时跳转到www.xxxx.com
RewriteCond为条件,多域名时多复制一行即可

iis6规则

在主机面板-网站基本功能中,点击isapi筛选器,点击第二个按钮”开启自定义url伪静态支持”,然后通过文件管理进入

others/discuz/httpd.conf中,强两行保留,其余代码删除,并复制以下代码到该文件中保存即可

RewriteCond %{HTTP:Host} ^xxxx1.com$ [NC]

RewriteCond %{HTTP:Host} ^xxxx2.com$ [NC]

RewriteRule (.*) http://www.xxxx1.com$1 [NC,R=301]

实现的效果是xxxx1.com和xxxx2.com访问时跳转到www.xxxx1.com

iis7规则

在主机面板-文件管理,进入wwwroot,新建一个文件,命名web.config,复制一些规则,保存即可

<?xml version=”1.0″ encoding=”UTF-8″?>

<configuration>

<system.webServer>

<rewrite>

<rules>

<rule name=”301Redirect” stopProcessing=”true”>

<match url=”(.*)” />

<conditions logicalGrouping=”MatchAny”>

<add input=”{HTTP_HOST}” pattern=”^xxxx1.com$” />

<add input=”{HTTP_HOST}” pattern=”^xxxx2.com$” />

</conditions>

<action type=”Redirect” url=”http://www.xxxx1.com/{R:0}” redirectType=”Permanent” />

</rule>

</rules>

</rewrite>

</system.webServer>

</configuration>

实现的效果是xxxx1.com和xxxx2.com访问时跳转到www.xxxx1.com



/template/Home/Zkeys2/PC/Static