IIS7.5配置web.config实现 wordpress 的伪静态
windows server 2008 R2 已经是各位的标配了吧,那如何在windows server 2008 R2下实现wordpress的伪静态呢?
系统环境:windows server 2008 R2+ IIS7.5 + PHP + MySQL
工具/原料
- IIS下的URL重写组件
- TXT文本编辑器:自带的txt或下载一个editplus,后者比较强大实用。
方法/步骤-
1
安装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 -
- 重启一下IIS,运行 “net stop iis” -> “net start iis”
- 配置 web.config 文件
在wordpress根目录,将以下内容保存为 web.config 文件。
- <p><em><?xml version="1.0" encoding="UTF-8"?></em></p><p><em><configuration></em></p><p><em> <system.webServer></em></p><p><em> <rewrite></em></p><p><em> <rules></em></p><p><em> <rule name="category"></em></p><p><em> <match url="category/?(.*)" /></em></p><p><em> <conditions logicalGrouping="MatchAll" trackAllCaptures="false" /></em></p><p><em> <action type="Rewrite" url="/index.php?category_name={R:1}" appendQueryString="false" logRewrittenUrl="false" /></em></p><p><em> </rule></em></p><p><em> <rule name="tags"></em></p><p><em> <match url="tag/?(.*)" /></em></p><p><em> <conditions logicalGrouping="MatchAll" trackAllCaptures="false" /></em></p><p><em> <action type="Rewrite" url="index.php?tag={R:1}" /></em></p><p><em> </rule></em></p><p><em> <rule name="Main Rule" stopProcessing="true"></em></p><p><em> <match url=".*" /></em></p><p><em> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"></em></p><p><em> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /></em></p><p><em> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /></em></p><p><em> </conditions></em></p><p><em> <action type="Rewrite" url="index.php/{R:0}" /></em></p><p><em> </rule></em></p><p><em> <rule name="wordpress" patternSyntax="Wildcard"></em></p><p><em> <match url="*" /></em></p><p><em> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"></em></p><p><em> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /></em></p><p><em> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /></em></p><p><em> </conditions></em></p><p><em> <action type="Rewrite" url="index.php" /></em></p><p><em> </rule></rules></em></p><p><em> </rewrite></em></p><p><em> </system.webServer></em></p><p><em></configuration></em
></p>
复制代码
- <p><em><?xml version="1.0" encoding="UTF-8"?></em></p><p><em><configuration></em></p><p><em> <system.webServer></em></p><p><em> <rewrite></em></p><p><em> <rules></em></p><p><em> <rule name="category"></em></p><p><em> <match url="category/?(.*)" /></em></p><p><em> <conditions logicalGrouping="MatchAll" trackAllCaptures="false" /></em></p><p><em> <action type="Rewrite" url="/index.php?category_name={R:1}" appendQueryString="false" logRewrittenUrl="false" /></em></p><p><em> </rule></em></p><p><em> <rule name="tags"></em></p><p><em> <match url="tag/?(.*)" /></em></p><p><em> <conditions logicalGrouping="MatchAll" trackAllCaptures="false" /></em></p><p><em> <action type="Rewrite" url="index.php?tag={R:1}" /></em></p><p><em> </rule></em></p><p><em> <rule name="Main Rule" stopProcessing="true"></em></p><p><em> <match url=".*" /></em></p><p><em> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"></em></p><p><em> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /></em></p><p><em> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /></em></p><p><em> </conditions></em></p><p><em> <action type="Rewrite" url="index.php/{R:0}" /></em></p><p><em> </rule></em></p><p><em> <rule name="wordpress" patternSyntax="Wildcard"></em></p><p><em> <match url="*" /></em></p><p><em> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"></em></p><p><em> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /></em></p><p><em> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /></em></p><p><em> </conditions></em></p><p><em> <action type="Rewrite" url="index.php" /></em></p><p><em> </rule></rules></em></p><p><em> </rewrite></em></p><p><em> </system.webServer></em></p><p><em></configuration></em
- 最后,刷新一下 wordpress ,打开几个链接看看,是不是正常了!
-