WordPress使用Lighttpd的rewrite规则

嗯,即使lighttpd和php都打开了rewrite,可是在Wordpress上,使用的话,还要做点手脚才行。

参考: Lighttpd wordpress Permalink rewrite 办法

Lighttpd virtualhost configuration ~ name-based virtual hosting 

我使用的办法如下:
创建 /etc/lighttpd/wp-rewrite.conf 文件,内容为

url.rewrite-once = (
“^” + wpdir + “(wp-.+).*/?” => “$0”,
“^” + wpdir + “(sitemap.xml)” => “$0”,
“^” + wpdir + “(xmlrpc.php)” => “$0”,
“^” + wpdir + “keyword/([A-Za-z_0-9-])/?$” => wpdir + “index.php?keyword=$1”,
“^” + wpdir + “(.+)/?$” => wpdir + “index.php/$1”
)

然后修改 /etc/lighttpd/lighttpd.conf

$HTTP[“host”] =~ “” {
var.wpdir = “/”
include “wp-rewrite.conf”
}

PS:$HTTP[“host”] =~ “” 中两个“”里面什么也没有是因为我没有用vhost,直接在根目录

发表评论