【问题标题】:Server variable used in URL Rewrite rule?URL重写规则中使用的服务器变量?
【发布时间】:2021-05-13 08:32:07
【问题描述】:

在 IIS 中,是否可以获取服务器变量的值以在 URL 重写规则条件中使用?

在我的 applicationHost.config 文件中,我有这个:

  <location path="api.domain-staging.site">
       <system.webServer>
            <aspNetCore>
                <environmentVariables>
                    <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Staging" />
                </environmentVariables>
            </aspNetCore>
        </system.webServer>
    </location>

我想在 URL 重写中添加一个条件,例如 {HOST_ASPNETCORE_ENVIRONMENT} = "Staging",以便能够确定是否使用该规则。

这可能吗?

【问题讨论】:

  • 这是 environmentVariables 而不是服务器变量。 / 元素的 元素指定了一个环境变量列表,当应用程序启动时,Internet Information Services (IIS) 10 将传递给工作进程。 元素包含 元素的集合,这些元素为每个环境变量定义了单独的名称/值对。

标签: iis url-rewrite-module


【解决方案1】:

环境变量不是“server variables

URL重写规则不支持环境变量,可以考虑ASP.NET Core URL Rewrite middleware

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-08
    • 2012-08-15
    • 2014-06-23
    • 2021-09-09
    • 2010-09-25
    • 2014-01-02
    • 1970-01-01
    相关资源
    最近更新 更多