plantroon Posted August 10, 2017 Share Posted August 10, 2017 (edited) I am trying to fix an older prestashop setup on a site and I am getting the following error on some products, that do not exist: Expected behavior is displaying a pretty 404 page. I tried using recommended configurations grabbed from the net as well as adding =404 to $uri $uri/ /index.php$is_args$args with no success. Here is my nginx configuration: server { server_name www.<SERVER NAME>; listen 80; root /storage/<SERVER NAME>/; rewrite ^/(.*)$ http://<SERVER NAME>/$1 permanent; } server { server_name www.<SERVER NAME>; listen 443; root /storage/<SERVER NAME>/; rewrite ^/(.*)$ https://<SERVER NAME>/$1 permanent; include /etc/nginx/conf.d/ssl-<SERVER NAME>.conf; } server { server_name <SERVER NAME>; listen 80; root /storage/<SERVER NAME>/; include /etc/nginx/conf.d/logging.conf; include /etc/nginx/conf.d/errors.conf; include /etc/nginx/conf.d/security.conf; # # PRESTASHOP rewrite # http://ix.sk/f7MhL # writable directories in docroot: # - log/ (-R) # - cache/ (-R, but should be probably revaluated) # index index.php; location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } location /cache/smarty/cache/ { return 404; } location / { rewrite ^/(.*)/img/cms/(.*).(jpe?g|png|gif)$ /img/cms/$2.$3 break; rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 break; rewrite ^/([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$1$2$3.jpg break; rewrite ^/([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$1$2$3$4.jpg break; rewrite ^/([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$1$2$3$4$5.jpg break; rewrite ^/([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg break; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg break; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg break; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg break; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg break; rewrite ^/c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2$3.jpg break; rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg break; rewrite ^/images_ie/?([^/]+)\.(jpe?g|png|gif)$ /js/jquery/plugins/fancybox/images/$1.$2 break; try_files $uri $uri/ /index.php$is_args$args; error_page 404 /index.php?controller=404; #location ~* \.(js|jsonp|css|png|jpg|jpeg|gif|ico)$ { # expires 604800s; # log_not_found off; #} } location ~ \.php$ { try_files $uri =404; include /etc/nginx/conf.d/fastcgi_pass.conf; fastcgi_read_timeout 600; } } server { server_name <SERVER NAME>; listen 443; root /storage/<SERVER NAME>/; include /etc/nginx/conf.d/ssl-<SERVER NAME>.conf; include /etc/nginx/conf.d/logging.conf; include /etc/nginx/conf.d/errors.conf; include /etc/nginx/conf.d/security.conf; # # PRESTASHOP rewrite # http://ix.sk/f7MhL # writable directories in docroot: # - log/ (-R) # - cache/ (-R, but should be probably revaluated) # index index.php; location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } location /cache/smarty/cache/ { return 404; } rewrite ^/(.*)/img/cms/(.*).(jpe?g|png|gif)$ /img/cms/$2.$3 break; rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last; rewrite ^/([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$1$2$3.jpg last; rewrite ^/([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last; rewrite ^/([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$1$2$3$4$5.jpg last; rewrite ^/([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg last; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg last; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg last; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg last; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg last; rewrite ^/c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2$3.jpg last; rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last; rewrite ^/images_ie/?([^/]+)\.(jpe?g|png|gif)$ /js/jquery/plugins/fancybox/images/$1.$2 last; error_page 404 /index.php?controller=404; try_files $uri $uri/ /index.php$is_args$args; location ~ \.php$ { try_files $uri =404; include /etc/nginx/conf.d/fastcgi_pass.conf; fastcgi_read_timeout 600; } location ~* \.(js|jsonp|css|png|jpg|jpeg|gif|ico)$ { expires 604800s; log_not_found off; } } Edited August 10, 2017 by plantroon (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now