404 Nginx配置Prestashop Multistore

时间:2019-07-09 04:50:30

标签: symfony nginx configuration prestashop

我正在将Prestashop与Nginx结合使用,并尝试设置Multistore。一间商店经营良好。但是第二家商店在jpg,js,css等上获得多个404。什么都没有正确显示。显然,我清除了所有缓存(服务器/浏览器)。

使用Nginx和Prestashop 7.1.5和php 7.0

这是我的配置。

server {


    server_name xxx.com   www.xxx.com;


    access_log /var/log/nginx/xxx.com.access.log rt_cache;
    error_log /var/log/nginx/xxx.com.error.log;


    root /var/www/xxx.com/htdocs;



    index index.php index.html index.htm;


    include common/php7.conf;  
    include common/locations-php7.conf;

    include /var/www/xxx.com/conf/nginx/*.conf;

 # Redirect 404 errors to prestashop
    error_page 404 /index.php?controller=404;



    # Global rewrite not depending on languages
  rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;

  rewrite "^/c/([0-9]+)(\-[_a-zA-Z0-9-]*)/(.*)\.jpg$" /img/c/$1$2.jpg last;
  rewrite "^/c/([_a-zA-Z-]+)/(.*)\.jpg$" /img/c/$1.jpg last;

  rewrite "^/([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/(\P{M}\p{M}*)*\.jpg$" /img/p/$1-$2$3.jpg last;
  rewrite "^/([0-9]+)\-([0-9]+)/(\P{M}\p{M}*)*\.jpg$" /img/p/$1-$2.jpg last;
  rewrite "^/([0-9])(\-[_a-zA-Z0-9-]*)?/(\P{M}\p{M}*)*\.jpg$" /img/p/$1/$1$2.jpg last;
  rewrite "^/([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/(\P{M}\p{M}*)*\.jpg$" /img/p/$1/$2/$1$2$3.jpg last;
  rewrite "^/([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/(\P{M}\p{M}*)*\.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-]*)?/(\P{M}\p{M}*)*\.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-]*)?/(\P{M}\p{M}*)*\.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-]*)?/(\P{M}\p{M}*)*\.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-]*)?/(\P{M}\p{M}*)*\.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-]*)?/(\P{M}\p{M}*)*\.jpg$" /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg last;

  rewrite "^/([0-9]+)\-(\P{M}\p{M}*)+\.html(.*)$" /index.php?controller=product&id_product=$1$3 last;
  rewrite "^/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$" /index.php?controller=category&id_category=$1$3 last;
  rewrite "^/([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$" /index.php?controller=product&id_product=$2$4 last;
  rewrite "^/([0-9]+)__([a-zA-Z0-9-]*)(.*)$" /index.php?controller=supplier&id_supplier=$1$3 last;
  rewrite "^/([0-9]+)_([a-zA-Z0-9-]*)(.*)$" /index.php?controller=manufacturer&id_manufacturer=$1$3 last;
  rewrite "^/content/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$" /index.php?controller=cms&id_cms=$1$3 last;
  rewrite "^/content/category/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$" /index.php?controller=cms&id_cms_category=$1$3 last;
  rewrite "^/module/([_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)$" /index.php?fc=module&module=$1&controller=$2 last;

  rewrite ^/page-not-found$ /index.php?controller=404 last;
  rewrite ^/address$ /index.php?controller=address last;  
  rewrite ^/addresses$ /index.php?controller=addresses last;
  rewrite ^/authentication$ /index.php?controller=authentication last;
  rewrite ^/best-sales$ /index.php?controller=best-sales last;
  rewrite ^/cart$ /index.php?controller=cart last;
  rewrite ^/contact-us$ /index.php?controller=contact-form last;
  rewrite ^/discount$ /index.php?controller=discount last;
  rewrite ^/guest-tracking$ /index.php?controller=guest-tracking last;
  rewrite ^/order-history$ /index.php?controller=history last;
  rewrite ^/identity$ /index.php?controller=identity last;
  rewrite ^/manufacturers$ /index.php?controller=manufacturer last;
  rewrite ^/my-account$ /index.php?controller=my-account last;
  rewrite ^/new-products$ /index.php?controller=new-products last;
  rewrite ^/order$ /index.php?controller=order last;
  rewrite ^/order-follow$ /index.php?controller=order-follow last;
  rewrite ^/quick-order$ /index.php?controller=order-opc last;
  rewrite ^/order-slip$ /index.php?controller=order-slip last;
  rewrite ^/password-recovery$ /index.php?controller=password last;
  rewrite ^/prices-drop$ /index.php?controller=prices-drop last;  
  rewrite ^/search$ /index.php?controller=search last;
  rewrite ^/sitemap$ /index.php?controller=sitemap last;
  rewrite ^/stores$ /index.php?controller=stores last;  
  rewrite ^/supplier$ /index.php?controller=supplier last;

    try_files $uri $uri/ /index.php?$args;



location ~ /\.well-known { allow all; } # ssl
location ~* \.(eot|otf|ttf|woff|woff2)$ { add_header Access-Control-Allow-Origin *; } 

location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|woff2|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|cur)$ {
        allow all; access_log off; log_not_found off; expires max;
}

location ~* ^.+\.(js|css)$ {allow all; access_log off; log_not_found off; expires 30d;}

       # Prevent injection of php files in directories a user can upload stuff
   location /upload {
       location ~ \.php$ { deny all; }
   }
   location /img {
       location ~ \.php$ {  deny all;}
   }



   # Ban access to source code directories
   location ~ ^/(app|bin|cache|classes|config|controllers|docs|localization|override|src|tests|tools|translations|travis-scripts|vendor)/ {
      deny all;
   }

   # Banned file types
   location ~ \.(htaccess|yml|log|twig|sass|git|tpl)$ {
       deny all;
   }


#MultiStore Configuration

location /mysecondshop/ {
            rewrite ^/mysecondshop/(.*)$ /$1 last;
            try_files $uri $uri/ /index.php?$args;
         }


    location /adminxxx/ { 
        if (!-e $request_filename) {
            rewrite ^/.*$ /adminxxx/index.php last;
        }
    }

 # PHP FPM part
    location ~ \.php$ {
        # Verify that the file exists, redirect to index if not
        try_files $fastcgi_script_name /index.php$uri&$args =404;

        fastcgi_index  index.php;

        # Environment variables for PHP
        fastcgi_split_path_info ^(.+\.php)(/.+)$;

        include       fastcgi_params;

        fastcgi_param PATH_INFO       $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        # [REQUIRED EDIT] Connection to PHP-FPM - choose one
        # fastcgi_pass 127.0.0.1:9000;
        fastcgi_pass unix:/var/run/php7.0-fpm.sock;

        fastcgi_keep_conn on;
        fastcgi_read_timeout 30s;
        fastcgi_send_timeout 30s;

        # In case of long loading or 502 / 504 errors
        # fastcgi_buffer_size 256k;
        # fastcgi_buffers 256 16k;
        # fastcgi_busy_buffers_size 256k;
        client_max_body_size 10M;
    }





}

Prestashop正在使用交响乐。不知道应该怪我是我的配置还是Prestashop / symfony。

欢迎提出任何建议。我已经在这个上浪费了几个小时。

0 个答案:

没有答案