系统环境:windows2008r2 + IIS7.5 + PHP + MySQL

工具:IIS下的URL重写组件、TXT文本编辑器:自带的txt或下载一个editplus,后者比较强大实用。

1、IIS7.5配置web.config实现 wordpress 的伪静态_百度经验

安装URL重写组件

a. 检查URL重写组件:配置伪静态需要URL重写组件,首先确认一下IIS是否安装了URL重写组件。在控制面板打开 Internet 信息服务(IIS)管理器,查看是否存在 “URL重写”,

b. 下载URL重写组件:无论是否安装,这里直接给一个微软官网的下载链接:http://download.microsoft.com/download/4/9/C/49CD28DB-4AA6-4A51-9437-AA001221F606/rewrite_x86_zh-CN.msi

配置web.config伪静态文件:在wordpress根目录,将以下内容保存为 web.config 文件。
<?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>