我将多商店Magento网站移到了其他域名。 为了重定向所有页面,我使用了一个htaccess文件。
旧域名是:
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 :(得分: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]