如果第一个域有文件夹路径,如何将一个域 301 重定向到另一个域
我想要从 www.olddomain.com 进行 301 重定向到 newdomain.com 的根目录,但无论旧域上的文件夹路径是什么,我都希望它能够正常工作。 例如:以下内容都应该重定向到 newdomain.com 的根目录
www.olddomain.com
olddomain.com
www.olddomain.com/folder/file.php
olddomain.com/folder/file.php
我如何使用 .htaccess 文件中的 Mod Rewrite 来做到这一点?
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
How can I do that with Mod Rewrite in the .htaccess file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试以下规则:
其中
old.example.com
是旧主机名,new.example.com
是新主机名。Try this rule:
Where
old.example.com
is the old host name andnew.example.com
the new.这也应该适合你。
This should also work for you.