web怎么做301跳转

时间:2022-12-06 01:19

web怎么做301跳转

web做301跳转的方法:

1.例如在web.config文件中的301格式:

<?xmlversion="1.0"encoding="UTF-8"?>

<configuration>

<system.webServer>

<rewrite>

<rules>

<rulename="Redirect(命名)"stopProcessing="true">

<matchurl="^(要重定向的页面)"/>

<conditionslogicalGrouping="MatchAll"trackAllCaptures="false"/>

<actiontype="Redirect"url="(重定向到的页面)"/>

</rule>

</rules>

</rewrite>

</system.webServer>

</configuration>

2.多个页面跳转,代码如下:

<?xmlversion="1.0"encoding="UTF-8"?>

<configuration>

<system.webServer>

<rewrite>

<rules>

<rulename="Redirect"stopProcessing="true">

<matchurl="^abc/001.html"/>

<conditionslogicalGrouping="MatchAll"trackAllCaptures="false"/>

<actiontype="Redirect"url="http://"/>

<rulename="Redirect2"stopProcessing="true">

<matchurl="^abc/002.html"/>

<conditionslogicalGrouping="MatchAll"trackAllCaptures="false"/>

<actiontype="Redirect"url="http://"/>

</rule>

</rules>

</rewrite>

</system.webServer>

</configuration>

//注意:多个页面跳转时,rulename不能相同

3.整站301跳转,代码如下

<?xmlversion="1.0"encoding="UTF-8"?>

<configuration>

<system.webServer>

<rewrite>

<rules>

<rulename="WWWRedirect"stopProcessing="true">

<matchurl=".*"/>

<conditions>

<addinput="{HTTP_HOST}"pattern="^需要转的域名$"/>

</conditions>

<actiontype="Redirect"url="http://要转到的域名/{R:0}"

redirectType="Permanent"/>

</rule>

</rules>

</rewrite>

</system.webServer>

</configuration>

标签:
随便看看
本类推荐
本类排行
热门标签

我国国家通讯社行不行啊细狗新年贺词祝福语2023年祝福语新年新年贺词新年贺词祝福语居家抗病毒小药箱除夕高速免费吗2022年除夕高速免费吗春联春联句子大全春联句子大全七字年夜饭十二道菜年夜饭十二道菜单年夜饭吃什么年夜饭吃什么菜吃年夜饭的寓意年夜饭黑芝麻菊花茶晒菊花茶腌腊肉送妈妈生日礼物汉白玉送闺蜜水钻送女人礼物爸爸生日送礼物送老公