MVC3 + WordPress IIS Url 重写规则 [英] MVC3 + WordPress IIS Url Rewriting Rules

查看:17
本文介绍了MVC3 + WordPress IIS Url 重写规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个位于 http://mydomain.com/mymvcapp/ 的 ASP.NET MVC3 网站.但是,网站 (mydomain.com) 的根目录包含一个运行 PHP 的 WordPress 站点.因此,我提出了以下 IIS URL 重写规则,以允许 WordPress 通过其重写机制正常运行:

I have a ASP.NET MVC3 website located at http://mydomain.com/mymvcapp/. However, the root of the webiste (mydomain.com) contains a WordPress site running PHP. Therefore, I put the following IIS URL Rewrite rule to allow WordPress to function correctly via its rewriting mechanisms:

    <rewrite>
        <rules>
            <rule name="wordpress" patternSyntax="Wildcard">
                <match url="*" />
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                </conditions>
                <action type="Rewrite" url="index.php"/>
            </rule>     
        </rules>
    </rewrite>

因此,有了这条规则,我的 WordPress 就可以完美运行,但是,我的 MVC 重写不起作用.我将如何更改此规则以允许 WordPress 和 MVC(在/mymvcapp/文件夹下)很好地共存?

So with this rule in place my WordPress functions perfectly, however, my MVC rewriting does NOT work. How would I alter this rule to allow both WordPress and MVC (under the /mymvcapp/ folder) to coexist nicely?

推荐答案

我自己想出来的.正则表达式可能是最强大的 YET 复杂/令人困惑的技术之一.但在这种情况下,patternSyntax 标志被设置为通配符,而不是正则表达式,这引起了我的困惑.希望这可以帮助其他人!=]

Figured it out on my own. Regex is probably one of the most powerful YET complicated / confusing technologies there is. But in this case the patternSyntax flag was set to Wildcard, not Regex, which caused my confusion. Hope this helps someone else out there! =]

    <rewrite>
        <rules>
            <rule name="wordpress" patternSyntax="Wildcard">
                <match url="*" />
                <conditions logicalGrouping="MatchAll">
                    <add input="{PATH_INFO}" pattern="/mymvcapp/*" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                </conditions>
                <action type="Rewrite" url="index.php" />
            </rule>     
        </rules>
    </rewrite>

这篇关于MVC3 + WordPress IIS Url 重写规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆