您好,欢迎访问一九零五行业门户网

Windows IIS 7.5 WordPress伪静态中文链接404错误解决办法

对于wordpress建站,虽然我们一直推荐用户使用linux系统,但是无可避免的依然会有很多用户由于种种原因选择了windows系统,并且也会经常有用户遇到中文链接404错误的问题,现在wordpress教程栏目针对windows iis 7.5下的中文链接(比如标签页)404错误提供一种解决方案。
首先,我们在wordpress安装目录下,新建一个“index2.php”文件,内容如下:
<?php// iis mod-rewriteif (isset($_server['http_x_original_url'])) { $_server['request_uri'] = $_server['http_x_original_url'];}// iis isapi_rewriteelse if (isset($_server['http_x_rewrite_url'])) { $_server['request_uri'] = $_server['http_x_rewrite_url'];} else { // use orig_path_info if there is no path_info if ( !isset($_server['path_info']) && isset($_server['orig_path_info']) ) $_server['path_info'] = $_server['orig_path_info'];// some iis + php configurations puts the script-name in the path-info (no need to append it twice) if ( isset($_server['path_info']) ) { if ( $_server['path_info'] == $_server['script_name'] ) $_server['request_uri'] = $_server['path_info']; else $_server['request_uri'] = $_server['script_name'] . $_server['path_info']; } // append the query string if it exists and isn't null if (isset($_server['query_string']) && !empty($_server['query_string'])) { $_server['request_uri'] .= '?' . $_server['query_string']; }}require("index.php");?>
然后在web.config中新增一条规则,并将此规则置于规则集合的顶部:
<rule name="chineseurl" stopprocessing="true"> <match url="/(tag|category)/(.*)" /> <action type="rewrite" url="index2.php" /></rule>
效果如下:
如果 wordpress 不是装在根目录,则需要更改“240e97e5c1f7106d2104c21f89d29587”为“bd29d000487d29266432d2e3da218a2f”。如果在固定链接设置里把默认的标签前缀和分类目录前缀(tag 和 category)改了,则更改这句里的对应内容即可。
以上方法只针对标签和分类里面的中文链接,如果您需要对网站的全部中文链接(比如文章、页面等)进行转化支持,那么可以不用添加最后一步的web.config规则,只需要直接编辑web.config,将上图里面的0157b008f81bd8ba7c7f72ff43a6e381改成07af0d71f454f710923abe0f69288867即可。
由于此方法是新建index2.php文件,并配合伪静态规则实现,所以不受wordpress更新升级影响,推荐使用。
以上就是windows iis 7.5 wordpress伪静态中文链接404错误解决办法的详细内容。
其它类似信息

推荐信息