我是Nette框架的新手,没有URL重写的经验,所以我为我的问题道歉。
Nette的路由器的默认语法是:
<presenter>/<action>[/<id>] 因此URL的格式为localhost/mypage/articles/view/35
我的问题是,如何配置lighttpd来接受这些urls并将它们绑定到有效内容?
我在文档中只找到了Apache的配置:http://doc.nette.org/en/2.1/troubleshooting#toc-how-to-allow-mod-rewrite
发布于 2014-10-13 18:59:00
尝试使用magnet-module + lua脚本
将磁铁模块添加到lighttpd模块
server.modules = (
...
"mod_magnet",
...
)lighttpd虚拟主机示例:
$HTTP["host"] =~ "^(example.com)$" {
server.document-root = "/var/www/example.com/document_root"
magnet.attract-physical-path-to = ( server.document-root + "/rewrite.lua" )
}在document_root文件夹中创建rewrite.lua文件(根据上面的设置)
attr = lighty.stat(lighty.env["physical.path"])
if (not attr) then
lighty.env["uri.path"] = "/index.php"
lighty.env["physical.rel-path"] = lighty.env["uri.path"]
lighty.env["physical.path"] = lighty.env["physical.doc-root"] .. lighty.env["physical.rel-path"]
end
-- uncomment below for debug output to stdout
-- print ("final file is " .. lighty.env["physical.path"])这篇文章的作者是来自nette forum thread的'edke‘用户
这也值得一试(或获得灵感):http://www.guyrutenberg.com/2008/05/24/clean-urls-permalinks-for-wordpress-on-lighttpd/
https://stackoverflow.com/questions/23251299
复制相似问题