apache .htaccess file on lighttpd

2019-06-28 03:07发布

问题:

RewriteEngine on
RewriteRule ^packed\.js$ pack.php?debug=0 [nc]
RewriteRule ^debug$ pack.php?debug=1 [nc]

That worked fine on apache in a .htaccess file placed in a specific directory. If I want to do this on lighttpd, do I have to add it in the config file or something?

Would I need to make any changes to these rules?

回答1:

lighttpd doesn't support .htaccess files like Apache httpd does. That's where the "light" in "lighttpd" comes into play.

You can, however, migrate these rules from Apache httpd's mod_rewrite to lighttpd's mod_rewrite. But be aware that the NC flag (case-insensitive matching) is not supported by lighttpd's mod_rewrite. If you are fine without it, you could simply use the following rewrite rules:

url.rewrite-once = (
    "^packed\.js$"  => "pack.php?debug=0",
    "^debug$" => "pack.php?debug=1" 
)

If you need the match to be case-insensitive, you'll probably need to invoke mod_magnet and a custom Lua script.