我有两个来自wordpress设置的web.config文件,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<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>
</system.webServer>
</configuration>
我想添加一些例外,例如在文件夹wordpress中,该规则未运行。
在我的情况下,我有2个wordpress安装了setting-&gt; permanentlinks-&gt;帖子名称,1个在根目录(http://example.com/)和其他在/ wordpress(http://example.com/wordpress)目录中。< / p>
第二个wordpress(/ wordpress)我更改web.config规则名称=“wordpress2”并且它可以工作,但如果我想查看样本页面(http://example.com/wordpress/sample-page)而不是页面重定向到404页面找不到
答案 0 :(得分:1)
更改下面显示的匹配网址,希望这会有所帮助。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url="^(.*)/$" />
<conditions logicalGrouping="MatchAll">
<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>
</system.webServer>
</configuration>