lighttpd開啟rewrite偽靜態方法

來源:互聯網
上載者:User

rewrite偽靜態是幾乎所有伺服器環境都可以配置的,下面我來介紹一下lighttpd環境下配置rewrite偽靜態方法,各位朋友可參考。

最近一直在推薦便宜的VPS,大家知道,便宜的VPS一般只有128MB,或者256MB記憶體,尤其是安裝免費的KLOXO面板之後,我們一般都選擇切換Apache為lighttpd來節省記憶體。

但是,隨之的問題卻來了,lighttpd是不支援.htaccess的,這樣我們如何來配置rewrite偽靜態呢?在google上轉了一圈之後,終於成功實現了lighttpd的偽靜態,我們要做的,就是把規則寫到lighttpd配置裡。下面,我以wordpress為例,來說下實現的方法。先上規則:

 代碼如下 複製代碼

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

我們登陸KLOXO後台,依次展開網域名稱,安裝WP的網域名稱,指令碼,lighttpd地址修正規則,然後將上面的規則填入右邊的輸入框,update,就可以了。如:


完成後,記得到服務裡面重啟lighttpd,這點很重要!不重啟可能是無效的!

【附DZ在lighttpd下開啟Rewrite規則】

 代碼如下 複製代碼

url.rewrite-once = (
"^/archiver/((fid|tid)-[w-]+.html)$" => "archiver/index.php?$1",
"^/forum-([0-9]+)-([0-9]+).html$" => "forumdisplay.php?fid=$1&page=$2",
"^/thread-([0-9]+)-([0-9]+)-([0-9]+).html$" => "viewthread.php?tid=$1&extra=page=$3&page=$2",
"^/space-(username|uid)-(.+).html$" => "space.php?$1=$2",
"^/tag-(.+).html$" => "tag.php?name=$1"
)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.