黄聪:wordpress用httpd.ini伪静态不支持中文解决办法

httpd.ini怎么写,就不说了,网上一搜一大堆,基本上都是一样的,都可以的。一般标准模板都是:

[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate
3600
RepeatLimit
32
# Protect httpd . ini and httpd . parse . errors files
# from accessing through HTTP
# Rules to ensure that normal content gets through

RewriteRule
/ software- files /(. * ) / software- files /$ 1 [L]
RewriteRule
/ images /(. * ) / images /$ 1 [L]
RewriteRule
/ sitemap . xml / sitemap . xml [L]
RewriteRule
/ favicon . ico / favicon . ico [L]
# For file-based wordpress content ( i . e . theme ), admin , etc .
RewriteRule
/ wp- (. * ) / wp- $ 1 [L]
# For normal wordpress content , via index . php
RewriteRule ^
/$ / index . php [L]
RewriteRule
/(. * ) / index . php /$ 1 [L]

主要是如果连接中含有中文的话,就会转向到404页面,是通过httpd.ini解决不了的,我们必须来修改源代码。

修改网站目录下wp-include/classes.php文件(请先行备份):
(最新3.1版需要修改的文件是wp-include/class-wp.php)

第一步:找到
$pathinfo = $_SERVER['PATH_INFO'];
修改为
$pathinfo = mb_convert_encoding($_SERVER['PATH_INFO'], 'UTF-8', 'GBK');

第二步:找到
$req_uri = $_SERVER['REQUEST_URI'];
修改为
$req_uri = mb_convert_encoding($_SERVER['REQUEST_URI'], 'UTF-8', 'GBK');

就这样,中文的TAG标签页等都可以打开了的。

其他

将 127.0.0.1/cts/index.php?p=1 转到 127.0.0.1/cts/p1.html

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase
/cts/
RewriteRule
^p([0-9]+)\.html$ index.php?p=$1
</IfModule>

你可能感兴趣的:(wordpress)