隐秘域名转发
将first.domain.com 秘密转发到second.domain.com 的最简单方法是什么?一直在 .htaccess: 中尝试使用以下代码:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^first.domain.com$
RewriteRule (.*)$ http://second.domain.com [R=301,L]
但
rewriteengine on
rewritecond %{REQUEST_URI} first.domain.com/
rewriterule (.*) http://second.domain.com [l,nc]
我一点运气都没有。我想在地址栏上保留“first.domain.com”,即使该页面已经位于 secondary.domain.com 上。提前致谢。
what is the easiest way to stealth forward this first.domain.com to second.domain.com? Been trying it with this codes in .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^first.domain.com$
RewriteRule (.*)$ http://second.domain.com [R=301,L]
and
rewriteengine on
rewritecond %{REQUEST_URI} first.domain.com/
rewriterule (.*) http://second.domain.com [l,nc]
But I'm having no luck at all. I want to retain "first.domain.com" on my address bar even when the page is already on second.domain.com. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想要第一个,但值得注意的是,您需要将
R=301
替换为P
(用于代理),并且您可以为规则匹配添加反向引用:这样,< a href="http://first.domain.com/some/file.html" rel="nofollow">http://first.domain.com/some/file.html 将被代理到 < a href="http://second.domain.com/some/file.html" rel="nofollow">http://second.domain.com/some/file.html 并且地址栏仍会显示:http://first.domain.com/some/file.html
You want the first, but notably you need to replace
R=301
withP
(for proxy), and you can add a backreference for the rule match:This way, http://first.domain.com/some/file.html will get proxied to http://second.domain.com/some/file.html and the address bar will still say: http://first.domain.com/some/file.html