I'm using Ruby on Rails and so
How to configurate nginx to redirect all responses to .php files to redirect on 404?
I don't quite understand the question (same as @dev0). If you want to send the user a 404 response when they try to access a php file, then put in a location block that will grab any php file and then do a simple return 404;
statement in it.
location ~* ^.+\.php {
return 404;
}
However, you'll need to do something different if you want to redirect a user to a specified PHP page when the user hits a 404 error. Is that it? And, if so, do you want to send them to one PHP page or a contextual PHP page? And do you want to pass arguments?
If you want to use a PHP page as a 404, then you can add the following to the main server block :
error_page 404 = /my_custom_404_page.php;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.