wordpress 默认的伪静态规则如下:
<?xml version="1.0" ?>
<rules>
<rule name="category_rewrite">
<match url="category/?(.*)"/>
<conditions logicalGrouping="MatchAll" trackAllCaptures="false"/>
<action appendQueryString="false" logRewrittenUrl="false" type="Rewrite" url="/index.php?category_name={R:1}"/>
</rule>
<rule name="tags_rewrite">
<match url="tag/?(.*)"/>
<conditions logicalGrouping="MatchAll" trackAllCaptures="false"/>
<action type="Rewrite" url="index.php?tag={R:1}"/>
</rule>
<rule name="Main Rule_rewrite" stopProcessing="true">
<match url=".*"/>
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
</conditions>
<action type="Rewrite" url="index.php/{R:0}"/>
</rule>
<rule name="wordpress_rewrite" patternSyntax="Wildcard">
<match url="*"/>
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<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>
在标红部分前加一个 /
,匹配规则变成了 /tag/?(.*)
,亲测后台显示正常。后续把中文分类名称增加英文别名即可。
<?xml version="1.0" ?>
<rules>
<rule name="category_rewrite">
<match url="/category/?(.*)"/>
<conditions logicalGrouping="MatchAll" trackAllCaptures="false"/>
<action appendQueryString="false" logRewrittenUrl="false" type="Rewrite" url="/index.php?category_name={R:1}"/>
</rule>
<rule name="tags_rewrite">
<match url="/tag/?(.*)"/>
<conditions logicalGrouping="MatchAll" trackAllCaptures="false"/>
<action type="Rewrite" url="index.php?tag={R:1}"/>
</rule>
<rule name="Main Rule_rewrite" stopProcessing="true">
<match url=".*"/>
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
</conditions>
<action type="Rewrite" url="index.php/{R:0}"/>
</rule>
<rule name="wordpress_rewrite" patternSyntax="Wildcard">
<match url="*"/>
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<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>