扫码关注官方订阅号
现在很多RESTful框架,或者支持pathinfo路由模式的框架,会把url里面的入口文件index.* 隐藏掉。那么,在这种情况下,怎么配置nginx,让他可以判断这个请求是动态的请求,需要程序处理,还是是静态文件的请求?
人生最曼妙的风景,竟是内心的淡定与从容!
location / { index index.php; # 重写到index if ($request_filename !~ (js|css|images|robots/.txt|index/.php.*) ) { rewrite ^/(.*)$ /index.php/$1 last; break; } }
server { root /site/root; location @cgi { include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME /site/root/index.php; } location / { try_files $uri @cgi; } }
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
人生最曼妙的风景,竟是内心的淡定与从容!