简体   繁体   English

将流量从站点B重定向到站点A,更改浏览器地址

[英]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.comsiteB.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.comsiteB.net访问者重定向到浏览器地址栏中的siteA.com ,因为siteB.comsiteB.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.

相关问题 无法通过 Google 将地址从旧站点更改为新站点 - Unable to Google Change Of Address from Old Site to New Site 为什么当流量从反向代理(端口 8080)转发到 Wordpress 站点侦听端口 80 时,浏览器中的 URL 会发生变化 - Why does URL change in browser when traffic forwarded from Reverse Proxy (port 8080) to Wordpress site listening on port 80 根据位置更改站点地址 - Change site address based on location 将流量重定向到“维护站点”页面-Amazon EC2上的WordPress - Redirect Traffic to “Site Down For Maintenance” Page - WordPress on Amazon EC2 是否可以仅在 WordPress 网站的主页上更改站点地址(站点 url)? - Is it possible to change site address(site url) only on homepage of the WordPress Website? Google Cloud WordPress 站点显示站点的 ip 地址而不是域名。 Cloudflare 未将流量重定向到站点 - Google Cloud WordPress site displays site's ip address instead of the domain name. Cloudflare not redirecting traffic to site 如何在 wordpress 多站点中将用户从站点“A”转换为站点“B” - How to Convert Users from Site 'A' to Site 'B' in wordpress multisite wordpress网站地址是指不同的网站 - wordpress site address is to a different site 重定向 Wordpress 站点以响应站点 - Redirect Wordpress Site to react site 重定向从桌面访问移动网站的用户 - Redirect users visiting mobile site from desktop
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM