nginx正则匹配的问题

【字号: 日期:2022-06-29浏览:47作者:雯心

问题描述

location / { index index.html index.htm index.php; rewrite ^/(.*)$ /index.php?/$1;}

配置文件的正则部分如上,但是诸如.css和.jpg结尾的文件也被rewrite了,请问怎么屏蔽

问题解答

回答1:

location / { if (!-e $request_filename){ rewrite ^(.*)$ /index.php?s=/$1 last; #rewrite模式 rewrite ^(.*)$ /index.php/$1 last; #pathinfo模式 任选其一 } }

相关文章: