Solution to Nginx tp 3.2. 3 404 problem
- 2021-09-25 00:17:16
- OfStack
Recently, I replaced Apache with nginx. When I moved the tp project to run, I found 404 error. It turned out that nginx does not support pathinfo mode, so I need to configure it myself
Below I configure
In the server configuration
location / {
#root html
index index.html index.htm index.php ;
if (!-e $request_filename) {
rewrite ^/test/tp/(.*)$ /test/tp/index.php/$1 last;
break;
}
location ~ \.php { # Pay attention here 1 Be sure 1 Sample, can't have $
set $script $uri;
set $path_info "/";
if ($uri ~ "^(.+\.php)(/.+)") {
set $script $1;
set $path_info $2;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php?IF_REWRITE=1;
include fastcgi_params;
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME $document_root/$script;
fastcgi_param SCRIPT_NAME $script;
}
After saving the configuration, restart nginx and the configuration is successful
Direct support for pseudo-static modes like/Index. html