2014-02-26 30 views
1

我將一個多商店Magento網站移動到其他域。 爲了重定向所有頁面,我使用了一個htaccess文件。htacces rewriteRule廣泛的網址的

舊的領域是:

www.olddomain.nl -> www.newdomain.nl 
www.olddomain.nl/categoryone -> www.newdomaincategoryone.nl 
www.olddomain.nl/categorytwo -> www.newdomaincategorytwo.nl 
www.olddomain.nl/categorythree -> www.newdomaincategorythree.nl 

這是工作,但在路徑更加廣泛,它不工作了。

例如:

http://www.oldomain.nl/categoryone/subcategory/product to 
http://www.newdomaincategoryone.nl/subcategory/product 

htaccess的代碼是:

<IfModule mod_rewrite.c> 
    Options +FollowSymlinks -MultiViews 
    RewriteEngine On 
    RewriteBase/

     RewriteCond %{HTTP_HOST} ^.*olddomain\.nl [OR] 
    RewriteCond %{HTTP_HOST} ^www\.olddomain\.nl [NC] 

    RewriteRule ^categoryone/?$(.*) http://www.newdomaincategoryone.nl/$1 [R=301,NC] 
    RewriteRule ^categorytwo/?$(.*) http://www.newdomaincategorytwo.nl/$1 [R=301,NC] 
    RewriteRule ^/?$(.*) http://www.newdomain.nl [R=301,NC] 
</IfModule> 

回答

0

您的規則和正則表達式是不正確的。

您可以使用此代碼:

Options +FollowSymlinks -MultiViews 
RewriteEngine On 
RewriteBase/

RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.nl$ [NC] 
RewriteRule ^categoryone(/.*)?$ http://www.newdomaincategoryone.nl$1 [R=301,NC,L] 

RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.nl$ [NC] 
RewriteRule ^categorytwo(/.*)?$ http://www.newdomaincategorytwo.nl$1 [R=301,NC,L] 

RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.nl$ [NC] 
RewriteRule ^/?$ http://www.newdomain.nl [R=301,NC,L]