Rewriting with lighttpd - how to remove file extensions

后端 未结 4 1029
囚心锁ツ
囚心锁ツ 2021-01-07 02:12

I would like to use lighttpd\'s mod_rewrite to allow requests without a specific file extension. For instance, I would like the following mappings to automatically work:

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-07 03:00

    Cassy and natbro got this very nearly right, but as user102008 commented, this erroneously rewrites any directory index. Adding a url.rewrite-once matching anything ending with a '/' seems to make it work.

    url.rewrite-once = (  "^(.*)/$" => "$1/" )
    url.rewrite-if-not-file = ( "^([^?]*)(\?.*)?$" => "$1.php$2" )
    

提交回复
热议问题