Win主机下WP3.1出现的几个错误

13年前 7

刚刚做好公司的网站,一连串的问题像日本的核泄漏一样一发不可收拾。

1、前几天通过修改httpd.ini方法把在win主机下的伪静态搞定了。代码如下:

    [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 /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]

当然这个首先的主机要装Rewrite 组件。

2、Win主机下wp3.1的中文tag出现404错误。不过好像不仅是tag中文的问题,只要是链接上有中文的都出现404错误。其他的倒是好改,直接改成拼音或者英文即可,但是tag有英文也有中文。通过搜索发现有同类的问题,但是WP3.1版本的文件名好像调整了,还好换汤不换药。具体操作如下:
找到wp-includes/class-wp.php,用notepad++或者dreamweaver打开,找到

if ( isset($_SERVER['PATH_INFO']) )
  $pathinfo = $_SERVER['PATH_INFO'];
else
  $pathinfo = '';
$pathinfo_array = explode('?', $pathinfo);
$pathinfo = str_replace("%", "%25", $pathinfo_array[0]);
$req_uri = $_SERVER['REQUEST_URI'];

改成

if ( isset($_SERVER['PATH_INFO']) )
  $pathinfo = mb_convert_encoding($_SERVER['PATH_INFO'], "UTF-8", "GBK");
else
  $pathinfo = '';
$pathinfo_array = explode('?', $pathinfo);
$pathinfo = str_replace("%", "%25", $pathinfo_array[0]);
$req_uri = mb_convert_encoding($_SERVER['REQUEST_URI'], "UTF-8", "GBK");

即可。
此修改原文在此

2011年4月11日更新 关于win主机完美伪静态规则httpd.ini如下:

[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
# 中文tag解决
RewriteRule /tag/(.*) /index.php?tag=$1
# sitemapxml
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]

7 条评论

  1. #1

    说实话,如果真想把WP博客做好,最好选用luinx主机

  2. #2

    Windows主机真滴对WP不是那么友好,发挥不了最大性能……而且流量一大,Windows主机信春哥也复活不了……

  3. #3

    我还在用3.0.1呵。升级好像现在都没有什么特别实用的功能了,所以索性不升了

评论 皇家元林 取消评论