[英]htaccess rewrite all pages to same page on another domain
So I've been looking but so far can;t find something that I'm looking for exactly. 所以我一直在寻找,但到目前为止都无法找到我正在寻找的东西。 Looked at this article How can I forward ALL pages to the same exact page on a different domain using .htaccess?
看看这篇文章如何使用.htaccess将所有页面转发到不同域上的同一页面? but it seems to only redirect my home page.
但它似乎只重定向我的主页。
Currently, I'm using WordPress and I need to be able to forward all pages to a new domain. 目前,我正在使用WordPress,我需要能够将所有页面转发到新域。 For example, domain1.com/about-us needs to go to domain2.com/about-us.
例如,domain1.com/about-us需要转到domain2.com/about-us。 But I have about 50 pages this needs to work on.
但我需要处理大约50页。 I would like to see if there is a 1-5 line code to use for this to work.
我想看看是否有一个1-5行代码用于此工作。
Thanks! 谢谢!
Try putting this (above any wordpress rules) in the htaccess file in domain1.com 's document root: 尝试将此(在任何wordpress规则之上)放在domain1.com的文档根目录中的htaccess文件中:
RewriteEngine On
RewriteCond %{HTTP_HOST} domain1.com [NC]
RewriteRule ^(.*)$ http://domain2.com/$1 [L,R=301]
If your 2 domains are one different webservers, or don't share a common document root, you can just use mod_alias, adding this to the htaccess file in domain1.com 's document root: 如果您的2个域是一个不同的Web服务器,或者不共享公共文档根,则可以使用mod_alias,将其添加到domain1.com的文档根目录中的htaccess文件中:
Redirect 301 / http://domain2.com/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.