我需要啓用的lighttpd 模式改寫它不應該顯示在index.php擴展....如何啓用的lighttpd國防部重寫
3
A
回答
5
如果我理解你的問題,你需要重寫/指數到/index.php。這應該做的伎倆。
server.modules += ("mod_rewrite")
url.rewrite-once = (
"^(.*)$" => "$1.php"
);
請注意,這也會轉發網址,例如/image.jpg - > /image.jpg.php。如果您需要更復雜的解決方案,請調整您的問題。
1
我相信他們可能一直在尋找如何重寫例如:/index.php/class/function to/class/function,比如Wordpress和PHP MVC Frameworks中使用的。
這很容易做到。用文本編輯器打開/etc/lighttpd/lighttpd.conf,並通過取消註釋來啓用重寫模塊(刪除#)。然後,它會是這個樣子:
server.modules = (
"mod_access",
"mod_alias",
"mod_compress",
"mod_redirect",
"mod_rewrite",
)
然後你只需將重寫正則表達式添加到同一個文件。在刪除index.php的情況下,這是我使用的:
url.rewrite-if-not-file = ("^/[^?]*(\?.*)?$" => "/index.php$1")
保存並退出,然後重新啓動lighttpd。在Debian中,你會怎麼做:sudo的服務lighttpd的重啓& &須藤服務lighttpd的狀態
我始終運行在第二個命令(後& &)檢查服務狀態,並確保沒有啓動錯誤。之後,你應該好好去!