由于他们都是Win主机,而我们做WP博客的朋友都知道喜欢弄伪静态什么的。而Win空间要想完美支持伪静态可得大费周章。

网上的教程几乎都是博客链接能伪静态,可中文标签的链接打不开,出现404错误页。而下面介绍的方法则是非常完美的。

下面就说说如何完美实现WP博客的伪静态:

1、写httpd.ini (用记事本即可,写好后放在根目录下OK)

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

或者通过以下的代码来实现:

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

2、比如博客地址含有中文,或者是标签是中文的,就会转向到404页面,是通过httpd.ini解决不了的,必须来修改源代码。

修改网站目录下wp-includes/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标签页等都可以打开了的。

现在看是不是可以完美解决了呢,,哈哈 总共就两步还是蛮简单的!

转载请注明:所以呢 – http://www.suoyine.com/archives/249.html