我有一个位于 mydomain/mymvcapp/ 的ASP.NET MVC3网站。但是,webiste的根目录(mydomain)包含一个运行PHP的WordPress站点。因此,我提出了以下IIS URL重写规则,以允许WordPress通过其重写机制正常运行:
I have a ASP.NET MVC3 website located at mydomain/mymvcapp/. However, the root of the webiste (mydomain) 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重写规则
发布评论