2014-04-23 40 views
1

我是Nette Framework的新手,沒有URL重寫的經驗,所以我爲我的問題表示歉意。nette,lighttpd - url重寫?

•奈特的路由器的默認語法是:

<presenter>/<action>[/<id>] 

所以網址格式localhost/mypage/articles/view/35

我的問題是如何配置的lighttpd接受這些網址,並將其綁定到有效的內容?

我發現只有配置爲Apache的文檔中:http://doc.nette.org/en/2.1/troubleshooting#toc-how-to-allow-mod-rewrite

+0

你需要的htaccess相當於FOT lighttpd的 - 見[類似的問題] [1] [1]:http://stackoverflow.com/questions/3654 765/Apache的htaccess的文件上,lighttpd的 – petrbel

回答

0

嘗試使用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"]) 

信用爲這個職位去「edke」用戶從nette forum thread

可能是值得嘗試的也是這個(或獲得啓發):http://www.guyrutenberg.com/2008/05/24/clean-urls-permalinks-for-wordpress-on-lighttpd/