Stealth Domain forwarding

亡梦爱人 提交于 2019-12-10 11:35:31

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/8509482/stealth-domain-forwarding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!