Wordpress在Win主机+IIS下设置伪静态

网络 · 2010-06-29

前一阵摸摸的服务器被封,额,我这几天就挪到了老外的空间上去,老外的Linux系统自然省心许多,直接一个.htaccess就安逸了,摸摸的服务器还是win的,要设置Wordpress的伪静态,相对来说要麻烦一些,不过侥幸成功了。
感谢天朝,希望摸摸牌服务器永不宕机永不卡机永不被封,阿米豆腐~
发布一下Rewrite规则,呃,给需要的朋友。


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


将文件保存成httpd.ini上传到空间根目录就可以了,当然,你的服务器得支持rewrite。
后台设置永久链接为自定义形式,貌似还有点问题,应该是编码的事情了,修改一下wp-include/classes.php当中的文件。


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");

这样就可以了。
顺道将htaccess也发一下,网上有不少教程,集中一下便于整理了。


RewriteEngine On

RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


wordpress 伪静态
Powered by Typecho Theme Jasmine 冀ICP备15024791号-3