jotaeme Posted October 30, 2015 Share Posted October 30, 2015 Hi everyone, I'm having some troubles when setting up my vhost configuration for a multisite store over nginx once I select the url friendly option. Everything is going well except the images of the second shop aren't displayed. I know it must be a rewrite rule that I'm missing, because at the very beginning I had the same issue with the main shop, but I was able to get it working by using these instruction inside server { ...} block: rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last; rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$1$2.jpg last; rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$1$2$3.jpg last; rewrite ^/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$1$2$3$4.jpg last; rewrite ^/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg last; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg last; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg last; rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$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])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg last; rewrite ^/c/([0-9]+)(-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*.jpg$ /img/c/$1$2.jpg last; rewrite ^/c/([a-zA-Z-]+)/[a-zA-Z0-9-]+.jpg$ /img/c/$1.jpg last; rewrite ^/([0-9]+)(-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*.jpg$ /img/c/$1$2.jpg last; Then I added: location /secondshop/ { rewrite ^/secondshop/(.*)$ /$1 last; try_files $uri $uri/ /index.php?$args; } But didn't work for my second shop site. As I said, the img aren't displayed. The routing is working just fine although. If I diselect the url-friendly option for this second store, then all work perfectly, but I want to implement the SEO optimization. The main project is placed in root, and the second store is placed inside: '/secondshop/' Any suggestion would be appreciated. Thank you. Link to comment Share on other sites More sharing options...
ashish.kpaul Posted December 2, 2015 Share Posted December 2, 2015 Waiting for the same, my config file is ---------------------- server { listen 80; server_name www.domain.com domain.com; root /var/www/domain; access_log /var/log/nginx/access_domain.com.log; error_log /var/log/nginx/error_domain.com.log; if ($http_host != "www.domain.com") { rewrite ^ http://www.domain.com$request_uri permanent; } index index.php index.html; location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). location ~ /\. { deny all; access_log off; log_not_found off; } # ESSENTIAL : Configure 404 Pages error_page 404 /404.html; # ESSENTIAL : Configure 50x Pages error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/www; } 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; try_files $uri $uri/ /index.php$is_args$args; error_page 404 /index.php?controller=404; 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; } #MultiStore Configuration location /client/ { rewrite ^/client/(.*)$ /$1 last; try_files $uri $uri/ /index.php?$args; } location /client-2/ { rewrite ^/client-2/(.*)$ /$1 last; try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { try_files $uri =404; include /etc/nginx/fastcgi_params; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/domain$fastcgi_script_name; fastcgi_intercept_errors on; fastcgi_read_timeout 300; } } Link to comment Share on other sites More sharing options...
jotaeme Posted December 2, 2015 Author Share Posted December 2, 2015 (edited) Waiting for the same, my config file is ---------------------- Hi there! I finally did it! As you may know by now, the whole problem is that Prestashop can not create/edit/whatever the rewrites rules by itself with Nginx. So I'd say that if you can set up an apache-environment-based, it'd be the easiest solution. But if your virtual host must be over Nginx as it happens to me, here you can find the solution: https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-as-a-reverse-proxy-for-apache Basically, you have to configure your nginx vhost as a proxy, and whenever it is needed, the apache web server will handle the problem. Hope it helps you Edited December 2, 2015 by jotaeme (see edit history) Link to comment Share on other sites More sharing options...
ashish.kpaul Posted December 3, 2015 Share Posted December 3, 2015 #Thanks #U Can Use This Config File, it's working for me #=============================================== ## we only want one access method into this store so rewrite xxxxx.com to www.xxxxx.com server { listen 80; server_name www.xxxxx.com xxxxx.com; root /var/www/pubLic.meNtor.orIgin.C0M/xxxxx/pay-to-xxxxx; access_log /var/log/nginx/access_tutor.xxxxx.com.log; error_log /var/log/nginx/error_tutor.xxxxx.com.log; if ($http_host != "www.xxxxx.com") { rewrite ^ http://www.xxxxx.com$request_uri permanent; } location / { index /index.php; rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last; rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$1$2.jpg last; rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$1$2$3.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.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.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.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.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.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.jpg last; rewrite ^/c/([0-9]+)(-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last; rewrite ^/c/([a-zA-Z-]+)(-[0-9]+)?/.+\.jpg$ /img/c/$1.jpg last; rewrite ^/([0-9]+)(-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last; try_files $uri $uri/ /index.php?$args; } # Do not log robots.txt or favicon.ico file requests location ~* ^/(favicon.ico|robots.txt)$ { access_log off; log_not_found off; } # Custom Prestashop 404 page error_page 404 /index.php?controller=404; # Set long expirey values for CSS and Images (assuming you dont change them too often) # location ~* ^.+.(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|htm|html|js|css|mp3|swf|ico|flv|xml) { # access_log off; # expires 30d; # } location = /robots.txt { allow all; access_log off; log_not_found off; } location = /favicon.ico { access_log off; log_not_found off; } # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban) location ~ /\. { deny all; } location ~ ~$ { access_log off; log_not_found off; deny all; } location = /CVS { deny all;} location ~ (\.inc\.php|\.tpl|\.sql|\.tpl\.php|\.db)$ { deny all; } location ~ /\.ht { deny all; } # Deny access to any files with a .php extension in the uploads directory # Works in sub-directory installs and also in multisite network # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban) location ~* /(?:uploads|files)/.*\.php$ { deny all; } location ~ ^/(README|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ { deny all; } location ~ ^/(bin|SQL)/ { deny all; } #MultiStore Configuration location /client/ { rewrite ^/client/(.*)$ /$1 last; try_files $uri $uri/ /index.php?$args; } location /client-1/ { rewrite ^/client-1/(.*)$ /$1 last; try_files $uri $uri/ /index.php?$args; } #php-fpm configuration location ~ \.php$ { try_files $uri =404; include /etc/nginx/fastcgi_params; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_intercept_errors on; fastcgi_read_timeout 300; } } Link to comment Share on other sites More sharing options...
ashish.kpaul Posted January 22, 2016 Share Posted January 22, 2016 these link might be helpful for you 1. https://gist.github.com/prestarocket/5280139/1fcb2ee08012631b1aaa9d70c254e597d1d38196 2. https://gist.github.com/gaillafr/e0a46cc27d0ae9440bfc/23cffe11db959da9717503d3591349350443337d 3. https://gist.github.com/gaillafr/e0a46cc27d0ae9440bfc Link to comment Share on other sites More sharing options...
Henrik41 Posted July 8, 2019 Share Posted July 8, 2019 I have the same issue but your configuration didn't work for me. Using Prestashop 1.7 and Nginx. 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