Jump to content

[SOLVED] Redirect to 404 page


j.kaspar

Recommended Posts

Hi,

 

I want to move my PS 1.6 to server with nginx. I am currently tuning the vhost file, to replace all features in apache's .htaccess

 

What I have problem with now, is redirection to error page (404). I want to use standard page, as is in default theme (404.tpl). I am not able to find a way how to actually call it. I know, that the page is a product of pagenotfoundcontroller.php and 404.tpl template, but have no idea how to call it. What will the URI look like. Could someone please advise?

 

Thank you

Edited by j.kaspar (see edit history)
Link to comment
Share on other sites

Scully, thank you. Actually I tried this method, because despite I don't precisely know what it does, I saw it in the original .htaccess. But this method ended up in error 500 because of "rewrite or internal redirection cycle while internally redirecting to "/index.php" while sending to client". That, i believe, is due to this directive:

 

        location @php {
            try_files $uri =404;
            include /etc/nginx/fastcgi_params;
            fastcgi_pass unix:/var/lib/php7.0-fpm/web3.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_intercept_errors on;
        }

do you have experience with it? Do you see a way out? Thank you

Link to comment
Share on other sites

  • 4 weeks later...

In the end, the solution was simple. The "main" @php location should look like this: 

(only the first line is important in this context)

 

        location @php {
            try_files $uri /index.php?controller=404;
            include /etc/nginx/fastcgi_params;
            fastcgi_pass unix:/var/lib/php7.0-fpm/web6.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_intercept_errors on;
        }

and then, the error pages doesn't contain the 404

 
 
        error_page 400 /error/400.html;
        error_page 401 /error/401.html;
        error_page 403 /error/403.html;
        error_page 405 /error/405.html;
        error_page 500 /error/500.html;
        error_page 502 /error/502.html;
        error_page 503 /error/503.html;
        error_page 504 /error/504.html;
        recursive_error_pages on;

        location = /error/400.html {
          internal;
        }
        location = /error/401.html {
          internal;
        }
        location = /error/403.html {
          internal;
        }
        location = /error/405.html {
          internal;
        }
        location = /error/500.html {
          internal;
        }
        location = /error/502.html {
          internal;
        }
        location = /error/503.html {
          internal;
        }
        location = /error/504.html {
          internal;
        }

this way, the dead loop is avoided. Every 404 ends up on the prestashop's /index.php?controller=404, and other error pages are pure html.

 

 

 

Scully, thank you. Actually I tried this method, because despite I don't precisely know what it does, I saw it in the original .htaccess. But this method ended up in error 500 because of "rewrite or internal redirection cycle while internally redirecting to "/index.php" while sending to client". That, i believe, is due to this directive:

 

        location @php {
            try_files $uri =404;
            include /etc/nginx/fastcgi_params;
            fastcgi_pass unix:/var/lib/php7.0-fpm/web3.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_intercept_errors on;
        }

do you have experience with it? Do you see a way out? Thank you

 

Edited by j.kaspar (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...