将流量从站点 B 重定向到站点 A,更改浏览器地址
我计划将 siteB.com
和 siteB.net
重定向到 siteA.com
。 (siteB.com/.net
是 siteA.com
的覆盖层,没有实际内容。)
我希望访问者访问 siteB.com
和 siteB.net
将被重定向到浏览器地址栏中的 siteA.com
,因为 siteB.com
和 的域名siteB.net
正在被淘汰,并将存在于仅名称。然而,现有的野外链接在一段时间内仍将需要重定向。
有人可以检查我的 .htaccess 规则并看看我是否正确吗?
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^siteB\.(com|net) [NC]
RewriteRule (.*) http://www.siteA.com/$1 [R=301,L]
谢谢
I am planning to redirect siteB.com
and siteB.net
to siteA.com
. (siteB.com/.net
is an overlay of siteA.com
and will have no actual content.)
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. 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?
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^siteB\.(com|net) [NC]
RewriteRule (.*) http://www.siteA.com/$1 [R=301,L]
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
唯一的建议是在
(com|net)
末尾添加 $,这样它就不会匹配 siteB.commerce.com 之类的内容,并不是说您可能会收到对该域的请求。并且可能将 RewriteRule 匹配绑定到^(.*)$
。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. And maybe bound the RewriteRule match to^(.*)$
.