apache往nginx去转,代码端用到了$_server['path_info'],对于nginx默认是不开启pathinfo的。所以我们就要手动开启
1,url重写
location / { //方法1 if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; break; } } location / { //方法2 try_files $uri $uri/ /index.php$uri; }
2,pathinfo设置
location ~ .*\.(php|php5)(.*)?$ //注意这块,配置重写的url { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_param path_info $fastcgi_path_info; fastcgi_param path_translated $document_root$fastcgi_path_info; include fastcgi.conf; }
这块要注意,location后正则要根据重写的url来决定。
以上就是nginx怎么开启pathinfo的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号