redirect to a .php file with try_files if required .php file not found

ST smntov at gmail.com
Wed Mar 14 20:32:22 UTC 2018


Hello,

I would like to redirect to /virtual_new.php with try_files if
required .php file not found, is it the right way to do so:

location ~ \.php$ {

        if ($args ~ "netcat_files/") {
             expires 7d;
             add_header Cache-Control "public";
         }

        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        try_files $uri /virtual_new.php =404;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root
$fastcgi_script_name;
        include fastcgi_params;
}

Thank you!



More information about the nginx mailing list