加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – iis将子域重定向到同一子域的子文件夹

发布时间:2020-12-16 09:53:17 所属栏目:asp.Net 来源:网络整理
导读:我有一个IIS站点,我试图使用ReWrite 2.0将特定的子域重定向到子文件夹.在我的IIS站点中,我将它绑定到两个不同的域: one.example.com two.example.com 当人们访问one.example.com时,我希望它什么都不做.当人们访问http://two.example.com时我希望他们被重定
我有一个IIS站点,我试图使用ReWrite 2.0将特定的子域重定向到子文件夹.在我的IIS站点中,我将它绑定到两个不同的域:

> one.example.com
> two.example.com

当人们访问one.example.com时,我希望它什么都不做.当人们访问http://two.example.com时我希望他们被重定向到http://two.example.com/subfolder.

谢谢你的帮助.

解决方法

您需要为HTTP_HOST添加匹配条件

<system.webServer>
    <rewrite>
        <rules>
            <rule name="two.example.com Redirect" stopProcessing="false">
                <match url="^/?$" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern=".*two.example.com.*" />
                </conditions>
                <action type="Redirect" redirectType="Found" url="http://two.example.com/subfolder/{R:0}" />
            </rule>
       </rules>
    </rewrite>
</system.webServer>

这是该模块的一个不错的整体参考:
http://www.iis.net/learn/extensions/url-rewrite-module/url-rewrite-module-configuration-reference

一个非常晚的答案,但希望它可以帮助某人.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读