用于迁移的magento nginx重定向

用于迁移的magento nginx重定向,magento,configuration,nginx,Magento,Configuration,Nginx,我有两个网站。比如说网站A和B。 两人都在使用Magento 几乎B中的所有产品也内置于A中 网站B将关闭,因此其所有匹配产品将重定向到网站A。 对于其他页面(不匹配的产品和其他url),将重定向到A的主页 我创建了一个脚本,将匹配的产品从B映射到A(放在namemapping.txt下),它包含大约20000个url 为了实现重定向,我使用了nginx-HttpMapModule(http://wiki.nginx.org/HttpMapModule) 我可以使用以下配置映射它: map $u

我有两个网站。比如说网站A和B。 两人都在使用Magento

几乎B中的所有产品也内置于A中

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

我创建了一个脚本,将匹配的产品从B映射到A(放在namemapping.txt下),它包含大约20000个url

为了实现重定向,我使用了nginx-HttpMapModule(http://wiki.nginx.org/HttpMapModule)

我可以使用以下配置映射它:

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

然后,我更改了配置:

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;
    }
    .
    .
    .
}
通过此配置,我仍然无法访问
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

但是这个配置也有问题,如果我输入
http://www.b.com/index.php/customer/account/login

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]