西数超哥博客
运维经验教程分享的博客

web.config各种跳转规则大全-持续更新

web.config各种跳转规则大全-持续更新 IIS 第1张

从不带www的域名跳转到带www的域名:

  1. <system.webServer>
  2. <rewrite>
  3. <rules>
  4. <rule name=“301Redirect_fengjienet” stopProcessing=“true”>
  5. <match url=“(.*)” />
  6. <conditions logicalGrouping=“MatchAny”>
  7. <add input=“{HTTP_HOST}” pattern=“^abc\.com$” />
  8. <add input=“{HTTP_HOST}” pattern=“^abc\.gotoip4\.com$” />
  9. </conditions>
  10. <action type=“Redirect” url=“http://www.tag.gg/{R:0}” redirectType=“Permanent” />
  11. </rule>
  12. </rules>
  13. </rewrite>
  14. </system.webServer>

同上,取反跳转,若不是www.tag.gg则跳转到www.tag.gg

  1. <?xml version=“1.0” encoding=“UTF-8”?>
  2. <configuration>
  3. <system.webServer>
  4. <rewrite>
  5. <rules>
  6. <rule name=“301Redirect_fengjienet” stopProcessing=“true”>
  7. <match url=“.*” />
  8. <conditions>
  9. <add input=“{HTTP_HOST}” pattern=“!^www.tag.gg$” />
  10. </conditions>
  11. <action type=“Redirect” url=“http://www.tag.gg/{R:0}” redirectType=“Permanent” />
  12. </rule>
  13. </rules>
  14. </rewrite>
  15. </system.webServer>
  16. </configuration>

匹配到某域名,跳转到某域名目录

  1. <system.webServer>
  2. <rewrite>
  3. <rules>
  4. <rule name=“301Redirect_fengjienet” stopProcessing=“true”>
  5. <match url=“.*” />
  6. <conditions>
  7. <add input=“{HTTP_HOST}” pattern=“^en.tag.gg$” />
  8. </conditions>
  9. <action type=“Redirect” url=“http://www.tag.gg/English/{R:0}” redirectType=“Permanent” />
  10. </rule>
  11. </rules>
  12. </rewrite>
  13. </system.webServer>

匹配访问到某页面,跳转到某域名

  1. <?xml version=“1.0” encoding=“UTF-8”?>
  2. <configuration>
  3. <system.webServer>
  4. <rewrite>
  5. <rules>
  6. <rule name=“index” stopProcessing=“true”>
  7. <match url=“^ShowNews.asp?(.*)$” />
  8. <conditions logicalGrouping=“MatchAll” trackAllCaptures=“false” />
  9. <action type=“Redirect” url=“http://www.tag.gg” appendQueryString=“false” />
  10. </rule>
  11. </rules>
  12. </rewrite>
  13. </system.webServer>
  14. </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>

访问某页面跳转到某域名三

  1. <?xml version=“1.0” encoding=“UTF-8”?>
  2. <configuration>
  3. <system.webServer>
  4. <rewrite>
  5. <rules>
  6. <rule name=“index” stopProcessing=“true”>
  7. <match url=“^index.html” />
  8. <conditions logicalGrouping=“MatchAll” trackAllCaptures=“false” />
  9. <action type=“Redirect” url=“http://www.tag.gg” />
  10. </rule>
  11. </rules>
  12. </rewrite>
  13. </system.webServer>
  14. </configuration>

通过web.config开启站点目录浏览

  1. <?xml version=“1.0” encoding=“UTF-8”?>
  2. <configuration>
  3. <system.webServer>
  4. <directoryBrowse enabled=“true” />
  5. </system.webServer>
  6. </configuration>

通过web.config开启程序报错

  1. <?xml version=“1.0” encoding=“UTF-8”?>
  2. <configuration>
  3. <system.webServer>
  4. <httpErrors errorMode=“Detailed” />
  5. </system.webServer>
  6. </configuration>

 

赞(0) 打赏
声明:本站发布的内容(图片、视频和文字)以原创、转载和分享网络内容为主,若涉及侵权请及时告知,将会在第一时间删除。本站原创内容未经允许不得转载:西数超哥 » web.config各种跳转规则大全-持续更新

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏