Welcome! Log In Create A New Profile

Advanced

Check the existence of a file

Posted by piero83 
Check the existence of a file
December 07, 2013 11:28AM
Hello,
I want to write a rewrite rule for checking the existence of an image file.
If the file exists in the file system, so the user can open it. Else if the file doesn't exist nginx must give 410 error.
The following code seems doesn't work. Which mistake I did?
Thanks

P


location ~* \.(js|json|css|png|jpg|jpeg|gif|swf|xml|ico|csv)$ {

if (!-f $request_filename){
rewrite ^(.*)$ /image-not-found.html redirect;
}


}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 243
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready