2012-12-29 68 views
2

我有2个网站。假设网站A和B. 两者都使用Magento。magento nginx迁移重定向

几乎所有的产品在B还内置A中

网站B将被关闭,因此其所有配套产品将被重定向到网站A. 对于其他网页(非匹配产品&其他网址)将被重定向到A的主页。

我创建了一个脚本来将匹配产品从B映射到A(放在名称mapping.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

然后,我改变了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; 
    } 
    . 
    . 
    . 
} 

通过这种构形,我仍然无法访问http://www.b.com/admin,但我可以访问http://www.b.com/index.php/admin但CSS和JS不加载,因为请求(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

Ë的mapping.txt的xample内容:

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

回答

0

您可以使用一个简单的域上的.htaccess这些通用的情况下重定向...

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