2012-12-29 67 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]