Answer the question
In order to leave comments, you need to log in
Nginx rewrite, how to disable *.php return?
The essence of the problem: you need to redirect the URLs /v1/... to v1.php, /v2/... to v2.php, while trying to open /v1.php gives a 404 error.
Config:
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location / {
rewrite ^/v1/(.*)$ /v1.php last;
rewrite ^/v2/(.*)$ /v2.php last;
rewrite ^(/resources/.*)$ $1 break;
}
Answer the question
In order to leave comments, you need to log in
For example like this
location /v1/ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root/v1.php;
include fastcgi_params;
}
location /v2/ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root/v2.php;
include fastcgi_params;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question