thinkphp nginx php-fpm url rewrite cause 404 error
The previous thinkphp system was deployed on Apache, considering that the concurrency performance of Nginx was much more powerful than Apache, so the thinkphp system was redeployed in NGINX+PHP-FPM mode on CentOS, and the results found such as
1 |
/index. PHP/Home/user/verify |
This type of URL nginx will report 404 errors, but changed to
1 |
/index. PHP? s=/home/user/verify |
Then can access, this shows that the previous URL Nginx does not support, then why does not support it? To solve this problem, we must first understand the thinkphp of several URL patterns.
thinkphp URL pattern
1. PathInfo mode
1 |
/index. PHP/Home/user/verify |
This URL format requires the server to support PathInfo.
2. Rewrite mode
Eliminate pseudo-static mode of index.php
3. Compatibility mode
Normal mode plus s=/parameter/or m=model&a=action
thinkphp URL Mode configuration
Modify the value of Url_model in File/application/common/conf.php
Nginx pathinfo Mode configuration
Nginx default is not support PathInfo mode, you need to manually add rewrite rules to support
1. Open the Site configuration file under the/nginx/conf/vhost directory.
2. Add the following location rule to the server node:
1 23 4 5 6 7 8 9 10 11 |
#以index. URI at the beginning of PHP Location~^/index. PHP(. *) { #如果文件或者路径不存在 if(! -e$request_filename) { The URI of the #将 pathinfo mode is rewritten into normal mode rewrite ^/index. PHP(. *)$ /index. PHP? s=$1 last ; break; } } |
3. Re-loading Nginx configuration information
Done!
The above describes the thinkphp nginx php-fpm url rewrite caused 404 errors, including the application aspects of the content, I hope that the PHP tutorial interested in a friend helpful.