Rewriting with lighttpd - how to remove file extensions

后端 未结 4 1072
囚心锁ツ
囚心锁ツ 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:06

    Without having tested it, but you can give it a shot:

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

    Basically it means

    • take everything but a question mark
    • and, if exists, take the question mark and everything following

    and you rewrite it to the first part, include the .php and add the last part again.

    Again: I haven't tested it yet.

提交回复
热议问题