[英]Redirect traffic from site B to site A, change browser address
I am planning to redirect siteB.com
and siteB.net
to siteA.com
. 我打算将
siteB.com
和siteB.net
重定向到siteA.com
。 ( siteB.com/.net
is an overlay of siteA.com
and will have no actual content.) (
siteB.com/.net
是覆盖siteA.com
并没有实际内容。)
I want visitors to siteB.com
and siteB.net
to be redirected to siteA.com
in the browser address bar, because the domain names for siteB.com
and siteB.net
are being phased out and will exist in name only. 我希望将
siteB.com
和siteB.net
访问者重定向到浏览器地址栏中的siteA.com
,因为siteB.com
和siteB.net
的域名正在逐步淘汰,并且仅以名称存在。 Existing links out in the wild, however, will continue to need redirects for some time. 但是,现有的野生链接仍然需要一段时间的重定向。
Can someone please check my .htaccess rules and see if I got it right? 有人可以检查我的.htaccess规则,看看我做对了吗?
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^siteB\.(com|net) [NC]
RewriteRule (.*) http://www.siteA.com/$1 [R=301,L]
Thanks 谢谢
Only suggestion is add a $ at the end of (com|net)
so that it won't match something like siteB.commerce.com , not that you'd be likely to get requests for that domain. 唯一的建议是在
(com|net)
的末尾添加一个$ ,以使其与siteB.commerce.com之类的内容不匹配,而不是您可能会收到该域的请求。 And maybe bound the RewriteRule match to ^(.*)$
. 也许将RewriteRule匹配项绑定到
^(.*)$
。
RewriteCond %{HTTP_HOST} ^siteB\.(com|net)$ [NC]
RewriteRule ^(.*)$ http://www.siteA.com/$1 [R=301,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.