繁体   English   中英

magento nginx迁移重定向

[英]magento nginx redirection for migration

我有2个网站。 假设网站A和B。两者都在使用Magento。

B中几乎所有产品都内置在A中。

网站B将要关闭,因此其所有匹配的产品都将重定向到网站A。对于其他页面(不匹配的产品和其他网址)将重定向到A的主页。

我创建了脚本来将匹配产品从B映射到A(将其放在名称mapping.txt下),其中包含大约20000 url。

为了进行重定向,我使用了nginx HttpMapModule(http://wiki.nginx.org/HttpMapModule)

我可以使用以下conf来映射它:

map $uri $new{
    default http://www.a.com/?ref=b;
    include /some/path/mapping.txt;
}

server {
    listen 80 ;
    listen 443 ssl;
    server_name www.b.com;
    root /some/path/www/b;

    #redirect b
    rewrite ^ $new redirect;

    location / {
        index index.html index.php;
        try_files $uri $uri/ @handler;
        expires 30d;
    }
    .
    .
    .
}

问题是,我希望能够访问B的管理员页面。 由于使用默认地图,因此我无法再访问http://www.b.com/admin

然后,我更改了conf:

map $uri $new{
    default http://www.a.com/?ref=b;
    include /some/path/mapping.txt;
}

server {
    listen 80 ;
    listen 443 ssl;
    server_name www.b.com;
    root /some/path/www/b;

    location / {
        #redirect b
        rewrite ^ $new redirect;
        index index.html index.php;
        try_files $uri $uri/ @handler;
        expires 30d;
    }
    .
    .
    .
}

通过此conf,我仍然无法访问http://www.b.com/admin但是我可以访问http://www.b.com/index.php/admin但由于请求( http://www.b.com/skin/.....http://www.b.com/js/.....重定向到http://www.a.com/?ref=b

但是这个conf也有问题,如果我输入http://www.b.com/index.php/customer/account/login ,它将不会重定向到A的主页

mapping.txt的示例内容:

/product-abc.html http://www.a.com/product-abc12.html;
/category-a/product-xyz.html http://www.a.com/product-xyz.html;
/category-b/category-d/product-123.html http://www.a.com/category-e/product-12z.html;

对于这些一般情况,您可以在.htaccess上使用简单的域重定向...

RewriteCond %{HTTP_HOST} ^www.a.com$ [NC]
RewriteRule ^(.*)$ http://www.b.com/$1 [R=301,L]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM