【问题标题】:URL Alias in IIS 8.5 Using URL Rewrite ModuleIIS 8.5 中的 URL 别名使用 URL 重写模块
【发布时间】:2016-08-30 18:29:52
【问题描述】:

我需要为大量应用程序创建易于记忆的重定向到长且难以记忆的路径的 URL。

即 subdomain.domain.edu/shortname 重定向到 https://www.subdomain.domain.edu/mainApplication/subfolder/page

我在 IIS 8.5 中使用 URL 重写模块,但是当我浏览到短别名时,我不断收到 404。我知道重写模块正在工作,因为我使用它来处理将 HTTP 重写为 HTTPS 并将 WWW 添加到 URL。

我的重写规则如下:

    <rewrite>
        <rules>
            <rule name="Easy to remember shortcut" stopProcessing="true">
                <match url=".*subdomain.domain.edu/shortname" />
                <conditions>
                    <add input="{URL}" pattern=".*/shortname" />
                </conditions>
                <action type="Redirect" url="https://www.subdomain.domain.edu/mainApplication/subfolder/page.aspx" />
            </rule>
        </rules>
    </rewrite>

当然这会返回 404。有什么想法吗?

如果在另一篇文章中已经有这个问题的答案,请原谅我,但是,我已经通读并尝试了 30 多篇关于 URL 重写模块的文章,但还没有找到实际创建别名的解决方案。

【问题讨论】:

  • 请检查我的答案,如果我错过了什么,请告诉我

标签: iis alias url-redirection


【解决方案1】:

Url 重写匹配条件将无法看到您的域,即如果 URL 是 https://www.subdomain.domain.edu/shortname,则匹配部分只能看到 shortname(domainname/ 之后的任何内容)。

要验证主机,我们需要在条件子句中添加。所以你的规则将如下所示

<rule name="shortnameURL" enabled="true" stopProcessing="true">
    <match url="shortname" />
    <action type="Redirect" url="mainApplication/subfolder/page" />
    <conditions>
        <add input="{HTTP_HOST}" pattern=".*subdomain.domain.edu" />
    </conditions>
</rule>

如果你在这里添加整个URL应该没问题

&lt;action type="Redirect" url="mainApplication/subfolder/page" /&gt; 如下

&lt;action type="Redirect" url="https://www.subdomain.domain.edu/mainApplication/subfolder/page" /&gt;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-18
    • 1970-01-01
    • 2015-04-28
    • 1970-01-01
    • 2013-08-16
    • 2011-12-04
    • 2012-06-01
    相关资源
    最近更新 更多