子网址上的Nginx vhost prestashop

时间:2017-04-08 12:06:31

标签: php nginx prestashop-1.6 vhosts

我在同一个域上有2个项目 - domain.ltd

在直接域上,我有一个symfony项目 - 这部分没问题。 但是为了我的缘故,我试图让旧的prestashop网站在子网址上,比如domain.ltd/old

所以我的vhost是:

# Redirect all HTTP traffic
server {
    listen   80;

    server_name www.domain.ltd domain.ltd;
    root /home/user/projects/old.domain.ltd/; 
    location = /{
        # On redirige toutes les requêtes vers HTTPS
        rewrite ^ https://www.domain.ltd$request_uri? permanent;
    }

    location /old {
        root /home/user/projects/old.domain.ltd/;

        index index.php;

        rewrite ^/old/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
        rewrite ^/old/([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$1$2$3.jpg last;
        rewrite ^/old/([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last;
        rewrite ^/old/([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 ^/old/([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 ^/old/([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 ^/old/([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 ^/old/([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 ^/old/([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 ^/old/c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2$3.jpg last;
        rewrite ^/old/c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last;
        rewrite ^/old/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 /old/index.php?controller=404;       

        location ~ ^/old/\.php$ {
            try_files $uri =404;
            root /home/user/projects/old.domain.ltd/;
            include /etc/nginx/fastcgi_params;
            fastcgi_pass unix:/var/run/php5-fpm-user.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_intercept_errors on;
        }

        access_log /var/log/nginx/domain.ltd.old.access.log;
        error_log /var/log/nginx/domain.ltd.old.error.log;
    }



    access_log /var/log/nginx/domain.ltd.old.access.log;
    error_log /var/log/nginx/domain.ltd.old.error.log;
}

# HTTPS request on symfony
server {
    listen 443 ssl;

    server_name www.domain.ltd;
    # this part works fine with my symfony project
}

我不明白为什么我的配置不起作用。当我进入后台页面时,我的网络浏览器会下载index.php文件。

如果有人有想法吗?

0 个答案:

没有答案