WordPress固定连接-lighttpd

内容目录

WordPress的rewrite规则不起作用

转自:http://zengrong.net/post/1786.htm

问题

WordPress中设定的固定链接不起作用,访问的时候显示404

解决

WordPress启用了固定链接功能后,会自动在网页根目录建立.htaccess文件,并在其中写入rewrite规则。Apache会读取这个规则,从而实现固定链接。

但是Lighttpd并不兼容Apache制订的rewrite规则。因此,需要为WordPress制订Lighttpd能够支持的rewrite规则。

我使用的规则如下:

url.rewrite = (
    "^/(wp-.+).*/?" => "$0",
    "^/(sitemap.xml)" => "$0",
    "^/(xmlrpc.php)" => "$0",
    "^/(.+)/?$" => "/index.php/$1"
)

或者这个:

url.rewrite-final = (
    # Exclude some directories from rewriting
    "^/(wp-admin|wp-includes|wp-content|gallery2)/(.*)" => "$0",
    # Exclude .php files at root from rewriting
    "^/(.*.php)" => "$0",
    # Handle permalinks and feeds
    "^/(.*)$" => "/index.php/$1"
)

ksweb的配置文件位于
Opened: /mnt/sdcard/ksweb/conf/lighttpd/localhost_1496a921-04bd-4cf6-8828-a1f87bce1cb2_host.conf

内容

[code lang="js"]
#Do not remove this label!
#_TYPE_=2
#======#begin_hostname (do not remove this label!)
$SERVER["socket"] == "0.0.0.0:81" {
#end_hostname (do not remove this label!)
#begin_docroot (do not remove this label!)
server.document-root = "/mnt/sdcard/WordPress"
#end_docroot (do not remove this label!)</pre>
url.rewrite-final = (
# Exclude some directories from rewriting
"^/(wp-admin|wp-includes|wp-content|gallery2)/(.*)" =&gt; "$0",
# Exclude .php files at root from rewriting
"^/(.*.php)" =&gt; "$0",
# Handle permalinks and feeds
"^/(.*)$" =&gt; "/index.php/$1"
)
}
[/code]

还可以修改conf配置信息,自定义404页面,加入这句话
server.error-handler-404 = "/404.html"

参考

 

发表回复