从不带www的域名跳转到带www的域名:
<system.webServer>
<rewrite>
<rules>
<rule name="301Redirect_fengjienet" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^abc\.com$" />
<add input="{HTTP_HOST}" pattern="^abc\.gotoip4\.com$" />
</conditions>
<action type="Redirect" url="http://www.tag.gg/{R:0}" redirectType="Permanent" /></rule>
</rules>
</rewrite>
</system.webServer>
同上,取反跳转,若不是www.tag.gg则跳转到www.tag.gg
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="301Redirect_fengjienet" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="!^www.tag.gg$" />
</conditions>
<action type="Redirect" url="http://www.tag.gg/{R:0}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
匹配到某域名,跳转到某域名目录
<system.webServer>
<rewrite>
<rules>
<rule name="301Redirect_fengjienet" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^en.tag.gg$" />
</conditions>
<action type="Redirect" url="http://www.tag.gg/English/{R:0}" redirectType="Permanent" /> </rule>
</rules>
</rewrite>
</system.webServer>
匹配访问到某页面,跳转到某域名
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="index" stopProcessing="true">
<match url="^ShowNews.asp?(.*)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="http://www.tag.gg" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
访问到某页面跳转到某域名二
(需求: http://www.test.com/xinde.asp?ID=1538&Action=show 301跳转到http://www.test.com/?p=1170 )
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="301Redirect1" stopProcessing="true">
<match url="xinde.asp" />
<conditions logicalGrouping="MatchAll">
<add input="{QUERY_STRING}" pattern="1538" />
<add input="{QUERY_STRING}" pattern="show" />
</conditions>
<action type="Redirect" url="/?p=575" appendQueryString="false" />
</rule>
<rule name="301Redirect111" stopProcessing="true">
<match url="xinde.asp" />
<conditions logicalGrouping="MatchAll">
<add input="{QUERY_STRING}" pattern="1477" />
<add input="{QUERY_STRING}" pattern="show" />
</conditions>
<action type="Redirect" url="/?p=1172" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
访问某页面跳转到某域名三
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="index" stopProcessing="true">
<match url="^index.html" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="http://www.tag.gg" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
通过web.config开启站点目录浏览
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
通过web.config开启程序报错
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpErrors errorMode="Detailed" />
</system.webServer>
</configuration>
文章评论 本文章有个评论