iis6,iis7+ wordpress路径重写配置/%postname%/配置
最近在window2003、window7下安装了WordPress,将自己发现的额问题和如何解决总结一下。当配置WordPress固定链接设置为下面这种结构时,注意需要配置iis6,iis7+增加通配符隐射到你使用的framework版本aspnet_isapi.dll上才行,要不会出现404错误,找不文件。
http://域名/%postname%/
window2003使用的是fastcgi搭建的php运行环境(参考:IIS6 fastcgi配置php运行环境),window7添加模块隐射到D:\WAPM\PHP\php-cgi.exe就可以了。

WordPress url重写为上面路径时,不包含index.php文件,这种路径是不存在通过url重写时,需要配置iis支持通配符映射,然后进行转发到php进行处理才行。
网上找到的都是居于asp版本的isapi_rewrite.dll的WordPress重写,这个需要付费,免费不支持单个站点的配置(而且经过测试这个重写组件在公司一台服务器window2003上设置无效,权限已经全部加上,不懂搞什么,这台服务器也安装过安全狗,但是安全狗的iis模块也一样不起作用,见鬼了。。),所以本示例使用asp.net的URLRewriter.dll这个组件,下载URLRewriter.dll后,将文件解压放在网站根目录的bin目录下,然后配置web.config增加如下规则。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
</configSections>
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>/wp-admin/(.*)</LookFor>
<SendTo>/wp-admin/$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>/wp-login.php</LookFor>
<SendTo>/wp-login.php</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>/wp-includes/(.*)</LookFor>
<SendTo>/wp-includes/$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>/wp-content/(.*)</LookFor>
<SendTo>/wp-content/$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>/index.php/(.*)</LookFor>
<SendTo>/index.php/$1?preview=true</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>/(.*)</LookFor>
<SendTo>/index.php/$1?preview=true</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
<system.web>
<httpModules>
<add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter" />
</httpModules>
<compilation defaultLanguage="c#" debug="true"></compilation>
<customErrors mode="Off"></customErrors>
<authentication mode="Windows" />
<authorization>
<allow users="*" />
</authorization>
<trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />
<sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" timeout="30" cookieless="false" />
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
</system.web>>
<!-----下面的配置是iis7通配符隐射加上的,iis6不需要,设置iis6也不会修改web.config文件,具体看下面如何配置----->
<system.webServer>
<handlers>
<add name="__WP__" path="*" verb="*" modules="IsapiModule" scriptProcessor="F:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
</handlers>
</system.webServer>
</configuration>
iis6添加通配符隐射支持WordPress url重写。
右键你的网站,属性,主目录,点击配置,插入(N),取消勾选“确认文件是否存在(v)”,这个步骤是最重要的,然后可执行文件选择你对应版本的aspnet_isapi.dll文件。

iis7+添加通配符隐射支持WordPress url重写,看上面贴出的web.config最后的说明,直接增加system.webServer配置即可。
或者打开iis7+,点击你的网站,双击右边的“处理程序隐射”,右键,“添加通配符脚本隐射”,名称随便起,可执行文件选择对应版本framework的aspnet_isapi.dll文件,确定即可。
这样WordPress不带index.php的固定链接设置/%postname%/就可以正常运行了。

加支付宝好友偷能量挖...

原创文章,转载请注明出处:iis6,iis7+ wordpress路径重写配置/%postname%/配置

