【发布时间】:2016-07-25 18:51:22
【问题描述】:
我需要从旧域重定向 301 到新域。我在我的 .htaccess 中尝试如下:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^olddomain.com$[NC,OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$[NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,NC,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(default|index)\.(html|php|htm)\ HTTP/ [NC]
RewriteRule ^(([^/]+/)*)(default|main|index)\.(html|php|htm)$ http://www.newdomain.com/$1 [R=301,NC]
Redirect 301 /folder/ http://www.newdomain.com
Redirect 301 /folder http://www.newdomain.com
Redirect 301 /folder/another-folder http://www.newdomain.com/new-folder/new-other-folder
Redirect 301 /folder/another-folder/ http://www.newdomain.com/new-folder/new-other-folder
Redirect 301 /folder/product.html http://www.newdomain.com/product
Redirect 301 /folder/other-product.html http://www.newdomain.com/new-other-product
</IfModule>
但它没有被正确重定向到上面代码中指定的每个页面或文件夹。我的旧网站在一个文件夹中。 我正在使用 Magento,需要重定向大约 200 页。我需要将文件夹中的旧域重定向到新域根目录,并将所有页面和文件夹重定向到新域中的相应页面和文件夹。我怎样才能做到这一点?
【问题讨论】:
标签: php .htaccess magento redirect mod-rewrite