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

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

问题描述

我有一个位于 http://mydomain.com/mymvcapp/ 的ASP.NET MVC3网站。但是,webiste的根目录(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标志设置为Wildcard,而不是Regex,这引起了我的困惑。希望这有助于其他人! =]

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天全站免登陆