【问题标题】:How can I setting up redirect in web.config file with dynamic parameter?如何使用动态参数在 web.config 文件中设置重定向?
【发布时间】:2020-04-30 19:36:17
【问题描述】:

我的网址是这样的:https://myhospital.com/Hospitals-and-Clinics/Hospitals/Hospital-A/Our-Doctors

我试试这个脚本:

<location path="Our-Doctors">
    <system.webServer>
        <httpRedirect enabled="true" destination="https://www.appointment.myhospital.com/" httpResponseStatus="Permanent" />
    </system.webServer>
</location>

在网络配置中

但它不起作用。它不会重定向到https://www.appointment.myhospital.com/

Hospital-A 是医院的名称

所以可以这样:

https://myhospital.com/Hospitals-and-Clinics/Hospitals/Hospital-B/Our-Doctors

https://myhospital.com/Hospitals-and-Clinics/Hospitals/Hospital-C/Our-Doctors

动态的

我该如何解决这个问题?

在这种情况下使用正则表达式吗?

【问题讨论】:

    标签: c# asp.net url web-config sitecore


    【解决方案1】:

    您的配置不起作用,因为您的路径错误。 应该是

    <location path="Hospitals-and-Clinics/Hospitals">
    

    您可以在您的情况下使用 URL Rewrite Module 模块。像这样:

    <rule name="Demo" stopProcessing="true">
        <match url="\/Our-Doctors$" />
        <conditions>
            <add input="{HTTP_HOST}" pattern="^(www\.)?myhospital\.com$" />
        </conditions>
        <action type="Redirect" url="https://www.appointment.myhospital.com/" />
    </rule>
    

    参考文档:https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module

    【讨论】:

      猜你喜欢
      • 2012-05-11
      • 1970-01-01
      • 2016-05-31
      • 1970-01-01
      • 2011-01-22
      • 2022-01-09
      • 2011-09-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多