remove .php from url with rewrite rule

前端 未结 3 1017
梦毁少年i
梦毁少年i 2021-01-24 13:00

I want to rewrite the url in nginx so that the .php extension can be omitted.

This is what I have, but this isn\'t working for me. Anyone any idea how to do

3条回答
  •  半阙折子戏
    2021-01-24 14:03

    Spent a while trying to get this to work properly. Both php files and other assets working:

    location / {
    
        if (!-e $request_filename){
            rewrite ^(.*)$ /$1.php;
        }
        try_files $uri $uri/ /index.php?$query_string;
    }
    

提交回复
热议问题