Jump to content

Nginx And Friendly Urls: Images Not Showing


Recommended Posts

I've got the friendly url thing working in Prestashop 1.6.1 on nginx 1.8.

The urls are working but the images of my products are not showing up.

I tried everything I could find but no luck.

 

Here's my config for domain.be (my PS is located in the subfolder /public_html)

server {
        listen *:80;


        server_name domain.be www.domain.be;

        root   /var/www/domain.be/web;



        index index.html index.htm index.php index.cgi index.pl index.xhtml;



        error_page 400 /error/400.html;
        error_page 401 /error/401.html;
        error_page 403 /error/403.html;
        error_page 404 /error/404.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;
        recursive_error_pages on;
        location = /error/400.html {

            internal;
        }
        location = /error/401.html {

            internal;
        }
        location = /error/403.html {

            internal;
        }
        location = /error/404.html {

            internal;
        }
        location = /error/405.html {

            internal;
        }
        location = /error/500.html {

            internal;
        }
        location = /error/502.html {

            internal;
        }
        location = /error/503.html {

            internal;
        }

        error_log /var/log/ispconfig/httpd/domain.be/error.log;
        access_log /var/log/ispconfig/httpd/domain.be/access.log combined;

        location ~ /\. {
            deny all;
            access_log off;
            log_not_found off;
        }

        location = /favicon.ico {
            log_not_found off;
            access_log off;
        }

        location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
        }

        location /stats/ {

            index index.html index.php;
            auth_basic "Members Only";
            auth_basic_user_file /var/www/clients/client0/web1/web/stats/.htpasswd_stats;
        }

        location ^~ /awstats-icon {
            alias /usr/share/awstats/icon;
        }

        location ~ \.php$ {
            try_files /90e10dcf6a7a13b323097b49a64d9159.htm @php;
        }

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




location /public_html {
        index index.php;

        rewrite ^/public_html/api/?(.*)$ /public_html/webservice/dispatcher.php?url=$1 last;
        rewrite ^/public_html/([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /public_html/img/p/$1/$1$2.jpg last;
        rewrite ^/public_html/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /public_html/img/p/$1/$2/$1$2$3.jpg last;
        rewrite ^/public_html/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /public_html/img/p/$1/$2/$3/$1$2$3$4.jpg last;
        rewrite ^/public_html/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /public_html/img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg last;
        rewrite ^/public_html/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /public_html/img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg last;
        rewrite ^/public_html/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /public_html/img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg last;
        rewrite ^/public_html/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /public_html/img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg last;
        rewrite ^/public_html/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /public_html/img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg last;
        rewrite ^/public_html/c/([0-9]+)(-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*.jpg$ /public_html/img/c/$1$2.jpg last;
        rewrite ^/public_html/c/([a-zA-Z-]+)/[a-zA-Z0-9-]+.jpg$ /public_html/img/c/$1.jpg last;
        rewrite ^/public_html/([0-9]+)(-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*.jpg$ /public_html/img/c/$1$2.jpg last;
        rewrite ^/public_html/images_ie/?([^/]+)\.(jpe?g|png|gif)$ /public_html/js/jquery/plugins/fancybox/images/$1.$2 last;
        
        
        
        
        if (!-e $request_filename) {
                rewrite ^/public_html/.*$ /public_html/index.php last;
        }

        location /public_html/ {
                try_files $uri $uri/ /public_html/index.php$args;
        }
}
        
        


        location ~* \.(gif)$ {
        expires 2592000s;
        }
        location ~* \.(jpeg|jpg)$ {
        expires 2592000s;
        }
        location ~* \.(png)$ {
        expires 2592000s;
        }
        location ~* \.(css)$ {
        expires 604800s;
        }
        location ~* \.(js|jsonp)$ {
        expires 604800s;
        }
        location ~* \.(js)$ {
        expires 604800s;
        }
        location ~* \.(ico)$ {
        expires 31536000s;
        }


}

Any solution or am I forced to switch to Magento?

Link to comment
Share on other sites

  • 1 month later...

I can't believe this is still an issue after so many users report this same problem over and over again.
Several versions of prestashop has been released and yet they cant fix a simple one line of code.

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...