【问题标题】:Issue with URL Rewriting - IIS & MVCURL 重写问题 - IIS 和 MVC
【发布时间】:2019-10-26 16:44:09
【问题描述】:

我试图为 PHP 页面的“永久重定向”构建一个重写规则到 MVC 站点。这是PHP站点的URL /Home/new-age-xxx.php & 我希望用户重定向到的 MVC 站点的 url "/home/new-age-xxx"

这是我的 URL 重写规则

<rule name="Imported Rule 1-599" stopProcessing="true">
     <match url="^home\new/-age/-xxx\.php$" ignoreCase="false" />
     <action type="Redirect" url="/home/new-age-xxx" appendQueryString="false" redirectType="Permanent" />
</rule>

它没有重定向到 /home/new-age-xxx,即使我试图将它移动到其他 url,例如 /login/index

有什么建议吗?

谢谢

【问题讨论】:

标签: asp.net-mvc iis url-rewriting


【解决方案1】:

您可以使用 bewlo url 重写规则将一个站点 url 重定向到另一个站点:

例如:

请求网址:http://www.sample2.com/home/new-age-123.php

重定向网址:http://www.example.com/home/new-age-123

 <rule name="reg redirect" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{REQUEST_URI}" pattern="/home/new\-age\-([0-9]{1,3}).php$" />
                </conditions>
                <action type="Redirect" url="http://www.example.com/home/new-age-{C:1}" appendQueryString="false" />
            </rule>

要了解有关 url 重写模块的更多信息,您可以参考 bewlo 链接:

Creating Rewrite Rules for the URL Rewrite Module

问候, 哈尔帕

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-18
    • 1970-01-01
    • 2012-10-03
    • 2016-11-03
    • 2016-01-09
    • 2014-10-23
    • 2011-10-21
    • 2017-12-14
    相关资源
    最近更新 更多