Redirect Prestashop、Nginx和重定向

Redirect Prestashop、Nginx和重定向,redirect,nginx,dns,prestashop-1.6,Redirect,Nginx,Dns,Prestashop 1.6,我遇到以下问题: 我们有两个Prestashop 1.6站点(比如bar.com和bar.foo.com)在Nginx+php fpm下运行。都在相同的VPS上,域具有相同的IP 我的bar.foo.com商店将我重定向到bar.com,尽管数据库、商店url等不同。事实上,我们还有其他页面,这些页面被重定向到同一个bar.com,并且它们都是foo.com的子域。值得一提的是,foo.com运行顺利 没有日志错误 下面是这些站点的配置,以及一个Nginx conf文件 bar.foo.com

我遇到以下问题:

我们有两个Prestashop 1.6站点(比如bar.com和bar.foo.com)在Nginx+php fpm下运行。都在相同的VPS上,域具有相同的IP

我的bar.foo.com商店将我重定向到bar.com,尽管数据库、商店url等不同。事实上,我们还有其他页面,这些页面被重定向到同一个bar.com,并且它们都是foo.com的子域。值得一提的是,foo.com运行顺利

没有日志错误

下面是这些站点的配置,以及一个Nginx conf文件

bar.foo.com

server {
       listen 80;
       server_name bar.foo.com;
       root /var/www/bar.foo.com/public_html;

       if ($http_host != "bar.foo.com") {
                 rewrite ^ http://bar.foo.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;
       }

       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;
       }

       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;
       }
}
bar.com配置

server {

       listen bar.com:80;
       server_name *.bar.com;
       root /var/www/bar.com/public_html;

       if ($http_host != "www.bar.com") {
                 rewrite ^ http://www.bar.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;
       }

       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;
       }

       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;
       }
}
nginx.conf

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # Logging Settings
    ##

    #rewrite_log on;

    access_log /var/log/nginx/access.log;
    #error_log /var/log/nginx/error.log notice;
    error_log /var/log/nginx/error.log;
    #error_log /var/log/nginx/error.log debug;


    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # nginx-naxsi config
    ##
    # Uncomment it if you installed nginx-naxsi
    ##

    #include /etc/nginx/naxsi_core.rules;

    ##
    # nginx-passenger config
    ##
    # Uncomment it if you installed nginx-passenger
    ##

    #passenger_root /usr;
    #passenger_ruby /usr/bin/ruby;

    ##
    # Virtual Host Configs
    ##


    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

我希望能有任何解决这个问题的想法。

所以,关于Prestashop(只注意标题)和 要解决此问题,请在bar.com conf中使用
listen 80,因此将有:

服务器{
听80;
server_name.bar.com;
root/var/www/bar.com/public_html;


此外,本页可能会有所帮助:

因此,关于Prestashop(只注意标题)和 要解决此问题,请在bar.com conf中使用
listen 80;
,这样将有:

服务器{
听80;
server_name.bar.com;
root/var/www/bar.com/public_html;


此外,此页面可能会有所帮助:

您确定重定向在Nginx端吗?当您有/var/www/(foo.)bar.com/public_html这样的空文件夹时发生了什么,它是否仍被重定向?是的。我这次从bar.com重定向到foo.bar.com。您确定重定向在Nginx端吗?当您有/var/www这样的空文件夹时会发生什么/(foo.)bar.com/public_html,它仍然被重定向吗?是的。我这次被从bar.com重定向到foo.bar.com,似乎这实际上是一个Prestashop(主题?)问题。相同的设置-两个不同的Web服务(一个虚拟,第二个带有Prestashop)对于虚拟页面来说,配置很好,但是第二个Web服务从foo.bar.com重定向到bar.com。我刚刚向您展示了您的Nginx配置是错误的,正是这一行
listen bar.com:80;
,您可以在这里找到类似的Q/A,例如,似乎这实际上是一个Prestashop(主题?)问题。相同的设置-两个不同的Web服务(一个虚拟,第二个带有Prestashop)和配置对于虚拟页面很好,但是第二个Web服务从foo.bar.com重定向到bar.com。我刚刚告诉你,你的Nginx配置是错误的,正是这一行
listen bar.com:80;
,你可以在这里找到类似的Q/A,例如。