首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >nette,lighttpd - url重写?

nette,lighttpd - url重写?
EN

Stack Overflow用户
提问于 2014-04-24 01:28:20
回答 1查看 404关注 0票数 1

我是Nette框架的新手,没有URL重写的经验,所以我为我的问题道歉。

Nette的路由器的默认语法是:

代码语言:javascript
复制
<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

EN

回答 1

Stack Overflow用户

发布于 2014-10-13 18:59:00

尝试使用magnet-module + lua脚本

将磁铁模块添加到lighttpd模块

代码语言:javascript
复制
server.modules = (
...
        "mod_magnet",
...  
)

lighttpd虚拟主机示例:

代码语言:javascript
复制
$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文件(根据上面的设置)

代码语言:javascript
复制
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/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23251299

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档