Nginx return 404 custom in IF statement

Discussion in 'Nginx' started by Hinze, Jul 26, 2016.

  1. #2
    I configured my page 404

    error_page 404 /erreur/404;

    Everything works well, except when I return 404 in if statement, I get the 404 not found by Nginx.

    My code:

    location ~ \.php$
    {
        if ($request_uri ~* \.php) # Block direct acces to [files].php
        {
            return 404;
        }
    
       fastcgi_intercept_errors on;
       try_files $uri =404;
       fastcgi_pass 127.0.0.1:9000;
       include fastcgi_params;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
    Code (markup):
     
    Last edited by a moderator: Jul 26, 2016
    Hinze, Jul 26, 2016 IP