隐秘域名转发

发布于 2024-12-21 08:46:08 字数 454 浏览 3 评论 0原文

将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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我纯我任性 2024-12-28 08:46:08

您想要第一个,但值得注意的是,您需要将 R=301 替换为 P (用于代理),并且您可以为规则匹配添加反向引用:

RewriteRule ^(.*)$ http://second.domain.com/$1 [P,L]

这样,< 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 with P (for proxy), and you can add a backreference for the rule match:

RewriteRule ^(.*)$ http://second.domain.com/$1 [P,L]

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文