我要301重定向:www.olddomain.com到newdomain.com的根源,但我想它不管文件夹路径是对旧域什么工作。例如:下面的应该都重定向到newdomain.com
I want to 301 redirect from: www.olddomain.com to the root of newdomain.com but I want it to work no matter what the folder path is on the old domain. eg: the following should all redirect to the root of newdomain.com
www.olddomain.com
olddomain.com
www.olddomain.com/folder/file.php
olddomain.com/folder/file.php
我怎样才能做到这一点与现代重写的.htaccess文件?
How can I do that with Mod Rewrite in the .htaccess file?
试试这个规则:
RewriteEngine on
RewriteCond %{HTTP_HOST} (^|.)old.example.com$
RewriteRule ^ http://new.example.com/ [L,R=301]
其中, old.example.com
是旧的主机名和 new.example.com
新