由于需要,把wordpress临时迁移到了iis7上,但是发现原来的主机设定的固定链接(伪静态)失效(404),栏目页(中文)和标签页打开也都是404,遂从网上找到了原因和解决办法,如下:
1、在根目录下创建文件web.config,把下列文本复制到文件中保存。(可以解决固定链接失效的问题)
<?xml version=”1.0″ encoding=”utf-8″?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name=”Main Rule” stopProcessing=”true”>
<match url=”.*” />
<conditions logicalGrouping=”MatchAll”>
<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>
2、打开wp-includes目录下的class-wp.php文件,找到下列两处代码进行修改。(可以解决中文栏目链接和中文标签失效的问题)
找到:list( $req_uri ) = explode( ‘?’, $_SERVER[‘REQUEST_URI’] );
修改为:list( $req_uri ) = explode( ‘?’, mb_convert_encoding($_SERVER[‘REQUEST_URI’], “UTF-8”, “GBK”));
找到:$pathinfo = isset( $_SERVER[‘PATH_INFO’] ) ? $_SERVER[‘PATH_INFO’] : ”;
修改为:$pathinfo = isset( $_SERVER[‘PATH_INFO’] ) ? mb_convert_encoding($_SERVER[‘PATH_INFO’], “UTF-8”, “GBK”) : ”;