Home >Backend Development >PHP Tutorial >thinkphp nginx php-fpm url rewrite causes 404 error
thinkphp nginx php-fpm url rewrite causes 404 error
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. , and found results such as
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 |
, which shows that I was able to access it later. The former URL is not supported by nginx, so why? Will it be supported? To solve this problem, you must first understand the several url modes of thinkPHP.
thinkPHP URL pattern
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
Normal mode plus s=/parameter/or m=model&a=action
thinkPHP URL mode configuration
Modify the value of URL_MODEL in the file /Application/Common/conf.php
1 |
'URL_MODEL'=>3 |
nginx pathinfo mode configuration
nginx does not support pathinfo mode by default Yes, you need to manually add rewrite rules to support
1 234567891011 |
#With uri location~^/index.php (.*) if(!-e $request_filename) Write in normal mode (.*)$ /index.php?s =$1 last; } } 3. Reload nginx configuration information
Done! The above introduces the 404 error caused by thinkphp nginx php-fpm url rewrite, including the application content. I hope it will be helpful to friends who are interested in PHP tutorials.
|