gpt4 book ai didi

url - IIS 重写模块和子应用程序

转载 作者:行者123 更新时间:2023-12-04 20:11:25 28 4
gpt4 key购买 nike

这是我部署的内容:

IIS deploy
testRedirect是一个空网站。所有子应用程序都是在应用程序中转换的子文件夹。它们都是 ASP .Net MVC 站点。

这是我要设置的内容:

  • Http://localhost/必须显示SiteName1的内容没有
    显示 Http://localhost/SiteName1/在地址栏中(它必须
    入住 Http://localhost/ )
  • Http://localhost/SiteName1/必须显示SiteName1的内容
    不显示 Http://localhost/SiteName1/在地址栏中
    (它必须保持 Http://localhost/ )
  • Http://localhost/SiteName2/显示SiteName2的内容和
    显示 Http://localhost/SiteName2/在地址栏中(SiteName3SiteName4 和任何其他网站的行为相同......)

  • 换句话说,我想要我的 SiteName1表现得像一个 首页 地点

    到目前为止,我尝试过的类似于@cheesemacfly here 提供的答案:
    <rules>
    <rule name="Redirect if SiteName1" stopProcessing="true">
    <match url="^SiteName1/(.*)$" />
    <action type="Redirect" url="{R:1}" />
    </rule>
    <rule name="Rewrite to sub folder">
    <match url="^.*$" />
    <action type="Rewrite" url="SiteName1/{R:0}" />
    </rule>
    </rules>

    它适用于案例 1 和 2,但不适用于其他案例。

    我试图添加这样的规则,但它没有成功......
    <rule name="if_not_SiteName1" stopProcessing="true">
    <match url="^SiteName1/(.*)$" negate="true" />
    <action type="None" />
    </rule>

    最佳答案

    我认为您最好的选择是仅在 url 时触发您已经拥有的重写规则。不 从您的子应用程序之一开始。

    它会是这样的:

    <rules>
    <rule name="Redirect if SiteName1" stopProcessing="true">
    <match url="^SiteName1/(.*)$" />
    <action type="Redirect" url="{R:1}" />
    </rule>
    <rule name="Rewrite to sub folder">
    <match url="^(SiteName2|SiteName3|SiteName4)/" negate="true" />
    <action type="Rewrite" url="SiteName1/{R:0}" />
    </rule>
    </rules>

    我们在 SiteName1/ 时保留重定向被请求(我们不需要更改它),但仅当请求的 url 不以 SiteName2/ 开头时才会触发重写规则或 SiteName3/SiteName4/ (这就是 url="^(SiteName2|SiteName3|SiteName4)/" 的意思,我们使用 negate="true" 仅当模式为 不匹配 时才触发规则)。

    关于url - IIS 重写模块和子应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16965413/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com