Jump to content

Images in Front Office do not Appear with Nginx and Friendly URLs


Recommended Posts

I've been working on my Prestashop instance, and I have not been able to get friendly URLs to work with my images, in Nginx.  When I activate the friendly URLs, the images are visible in the backend, but whether I'm in the category list, or looking at the product, the web inspector says it's a 404.    

 

The current permissions on /img is 777 and ownership is correct.  

 

I have tried regenerating the images a bunch of times.  

 

My nginx site file: 

server {
        listen 80;
        server_name name.com;
        return 301 http://www.name.com$request_uri;
}

server {
        listen      80;
        server_name www.name.com;
        root /usr/share/nginx/www;
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log notice;
        error_page 404 /usr/share/nginx/www/Error_Page/404.html;

    location / {
        index index.php;
        if (!-e $request_filename) {
           rewrite ^/(.+)$ /index.php?q=$1 last;
        }
    }

    location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
        expires 365d;
    }

    location ~*  \.(pdf)$ {
        expires 30d;
    }

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

        location /. { ## Disable .htaccess and other hidden files
            return 404;
        }
       location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
            rewrite ^(.*.php)/ $1 last;
        }

        error_page 404 /404.html;

location ~ .php$ {
            # connect to a unix domain-socket:
            fastcgi_pass   unix:/var/run/php5-fpm.sock;
            fastcgi_index  index.php;

            fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
            fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;

            fastcgi_buffer_size 128k;
            fastcgi_buffers 256 16k;
            fastcgi_busy_buffers_size 256k;
            fastcgi_temp_file_write_size 256k;

            # This file is present on Debian systems..
            include fastcgi_params;
        }
    }

I don't know what else to do, the unfriendly URLs are very ugly.  

Link to comment
Share on other sites

  • 3 months later...
  • 9 months later...
  • 1 month later...
×
×
  • Create New...