There are questions remain, We'll search for the answers together. But one thing we known for sure,the future is not set!

【原创文章】windows 2003 IIS6完美运行最新wordpress的解决方法

wordpress 百蔬君 4560℃ 已收录 0评论

最近用wordpress架设了这个百蔬君博客,感觉还不错。遇到几个小问题,记录下。

windows 2003的系统,运行环境IIS6,2003玩的太熟悉了,舍不得升级,wordpress也只能屈尊于iis下了。

一般来说,安装wordpress后需要安装一些必须的插件,比如站点地图baidu sitemap,w3 cache缓存插件,有个主题还使用了avatar图标缓存。

wordpress与windows 2003最大的问题可能是伪静态的问题,很多都说这个环境下运行wordpress不好。其实也没有那么绝对的,正好这个系统装了isapi rewrite,可以用上。

下载的最新版的wordpress系统wordpress-4.3.1-zh_CN,isapi rewrite好像是isapi rewrite 0073 full版。本来开始还没注意这个伪静态,但是当我使用wordpress的搜索功能时,当搜索英文时,没问题,但是搜索中文时,出现乱码,并且无法正确搜索。

需要修改网站根目录下面的https.ini。

本来的一般通用规则为:

[ISAPI_Rewrite]
# Defend your computer from some worm attacks
#RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O]
# 3600 = 1 hour

CacheClockRate 3600
RepeatLimit 32

RewriteRule /tag/(.*) /index\.php\?tag=$1
RewriteRule /software-files/(.*) /software-files/$1 [L]
RewriteRule /images/(.*) /images/$1 [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]

 

这里需要修改下tag规则为

#RewriteRule /tag/(.*) /index\.php\?tag=$1
RewriteRule /tag/[^/]+)/([^/]+)/?([0-9]+)?/ /index.php?tag=$1&paged=$3 [L]

 

由于使用了站点地图和avatar,那么这两个也需要加入到https.ini中。

完整的https.ini规则为

[ISAPI_Rewrite]
# Defend your computer from some worm attacks
#RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O]
# 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 /tag/(.*) /index\.php\?tag=$1
RewriteRule /tag/[^/]+)/([^/]+)/?([0-9]+)?/ /index.php?tag=$1&paged=$3 [L]
RewriteRule /software-files/(.*) /software-files/$1 [L]
RewriteRule /avatar/(.*) /avatar/$1 [L]
RewriteRule /images/(.*) /images/$1 [L]
RewriteRule /sitemap.xml /sitemap_baidu.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]

 

对于搜索中文出现错误的问题,需要修改一个文件。打开wp-includes\class-wp.php

约155行

$pathinfo = isset( $_SERVER['PATH_INFO'] ) ? $_SERVER['PATH_INFO) : '';

修改为

$pathinfo = isset( $_SERVER['PATH_INFO'] ) ? mb_convert_encoding($_SERVER['PATH_INFO'],"UTF-8","GBK") : '';

 

约159行

list( $req_uri ) = explode( '?', $_SERVER['REQUEST_URI);

修改为

list( $req_uri ) = explode( '?', mb_convert_encoding($_SERVER['REQUEST_URI'],"UTF-8","GBK"));

 

转码之后再搜索中文,就不会乱码了。

 

 

 

 

 

 

 

 

 

 

 

转载请注明:百蔬君 » 【原创文章】windows 2003 IIS6完美运行最新wordpress的解决方法

喜欢 (1)or分享 (0)
发表我的评论
取消评论

请证明您不是机器人(^v^):

表情