How to enable mod rewrite in lighttpd

I need to enable rewrite mode in lighttpd it should not display the index.php extension ....

+3
source share
2 answers

If I understand your question, you need to rewrite / index / index.php. That should do the trick.

server.modules += ("mod_rewrite")
url.rewrite-once = ( 
    "^(.*)$" => "$1.php"
);

Note that this will also redirect the url, e.g. /image.jpg -> /image.jpg.php. If you need a more complicated solution, adjust your question.

+5
source

I believe that they may have looked for ways to rewrite, for example: /index.php/class/function to / class / function, for example, used in Wordpress and the PHP MVC Framework.

. /etc/lighttpd/lighttpd.conf , ( #). :

server.modules = (
    "mod_access",
    "mod_alias",
    "mod_compress",
    "mod_redirect",
    "mod_rewrite",

)

rewrite . index.php , :

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

, lighttpd. Debian : sudo service lighttpd restart && & & sudo service lighttpd

( & &) . !

+1

Source: https://habr.com/ru/post/1744464/


All Articles