zoukankan      html  css  js  c++  java
  • IIS URL Rewrite redirect from one Domain to another

    IIS URL Rewrite enables Web administrators to create powerful rules to implement URLs that are easier for users to remember and easier for search engines to find.
    For more information you can read the below url: http://www.iis.net/downloads/microsoft/url-rewrite

    See the below example redirect from one Domain to another:

    IIS URL Rewrite will add the rewrite rules into web.config

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="Domain switch" stopProcessing="true">
                        <match url=".*" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="(www.)?site1.com" />
                        </conditions>
                        <action type="Redirect" url="http://www.site2.nl/{R:0}" />
                    </rule>
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>

    How can we skip the "/page" when we redirect one Domain to another?

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="Domain switch" stopProcessing="true">
                        <match url=".*" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="(www.)?site1.com" />
                            <add input="{URL}" pattern="^/page.*" negate="true" />
                        </conditions>
                        <action type="Redirect" url="http://www.site2.nl/{R:0}" />
                    </rule>
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>

    How can we redirect non-www to www?

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="Redirect non-www to www" stopProcessing="true">
                        <match url=".*" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="^site.com$" />
                        </conditions>
                        <action type="Redirect" url="http://www.site.com/{R:0}" />
                    </rule>
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>
  • 相关阅读:
    Qt编写安防视频监控系统(界面很漂亮)
    Qt编写数据可视化大屏界面电子看板系统
    Qt开源作品35-秘钥生成器
    Qt开源作品34-qwt无需插件源码
    Qt开源作品33-图片开关控件
    Qt开源作品32-文本框回车焦点下移
    Qt开源作品31-屏幕截图控件
    Qt开源作品30-农历控件
    Qt开源作品29-NTP服务器时间同步
    Qt开源作品28-邮件发送工具
  • 原文地址:https://www.cnblogs.com/zhangpengc/p/4899471.html
Copyright © 2011-2022 走看看