IIS7.5配置 web.config 实现 wordpress 的伪静态

本地环境是 windows7 + IIS7.5 + PHP,配置伪静态还需要URL重写组件,如果IIS没有安装上,可以先下载一个:

下载 URL重写组件

安装完后,重启一下IIS,在wordpress根目录将以下内容保存为 web.config 文件,参考一下:IIS7配置 web.config 实现 Discuz! X3 的伪静态

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
                <rule name="category">
                    <match url="category/?(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="/index.php?category_name={R:1}" appendQueryString="false" logRewrittenUrl="false" />
                </rule>
                <rule name="tags">
                    <match url="tag/?(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="index.php?tag={R:1}" />
                </rule>
                <rule name="Main Rule" 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" 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>
    </rewrite>
  </system.webServer>
</configuration>