The thinkphp system was previously deployed on apache. Considering that nginx is much more powerful than apache in terms of concurrency performance, the thinkphp system was redeployed on centos in nginx php-fpm mode. As a result, we found that
1 | /index.php/home/user/verify |
This kind of url nginx will report a 404 error, but change it to
1 | /index.php?s=/home/user/verify |
can be accessed later, which means that the former URL is not supported by nginx, so why is it not supported? To solve this problem, you must first understand the several url modes of thinkPHP.
1 | /index.php/home/user/verify |
This url format requires the server to support pathinfo
1 | /?s=/home/user/verify |
Remove the pseudo-static mode of index.php
For normal mode, add s=/parameter/ or m=model&a=action
Modify the value of URL_MODEL in the file /Application/Common/conf.php
1 | 'URL_MODEL' => 3 |
nginx does not support pathinfo mode by default. You need to manually add rewrite rules to support
1 2 3 4 5 6 7 8 9 10 11 | #以index.php开头的uri location ~ ^/index.php(.*) { #如果文件或者路径不存在 if (!-e $request_filename) { #将pathinfo模式的uri重写成普通模式 rewrite ^/index.php(.*)$ /index.php?s=$1 last; break; } } |
1 | service nginx reload |