Home  >  Q&A  >  body text

rewrite - Nginx configuration Thinkphp plus .php

The website is built using Thinkphp, and Nginx is used as the proxy server.

Nginx rewrite configuration is as follows:

if (!-e $request_filename) {
        rewrite  ^(.*)$  /index.php?s=  last;
        break;
}

Normal address:

http://aaa.com/api/home?id=1

You can also access it if you want to change it to the following (add .php suffix):

http://aaa.com/api/home.php?id=1

Please tell me how to configure Nginx?

怪我咯怪我咯2713 days ago417

reply all(1)I'll reply

  • 漂亮男人

    漂亮男人2017-05-16 17:18:55

    Match the directory under the api:

    rewrite /api/(.*)\.php /api/ permanent;

    reply
    0
  • Cancelreply