rewrite - Nginx配置Thinkphp加上.php

浏览:44日期:2022-07-17

问题描述

用Thinkphp搭的网站,Nginx做代理服务器。

Nginx rewrite配置如下:

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

正常地址:

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

想改成下面这样也能访问(加上后缀 .php):

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

请教Nginx如何配置?

问题解答

回答1:

匹配api下的目录:

rewrite /api/(.*).php /api/$1 permanent;

相关文章: