RewriteCond 更改显示的主机,但不更改服务器
输入标题让我相信,出于安全考虑,这可能是不可能的,但无论如何我都会问。我的服务器上运行着短代码支持,我们称之为 xx.yy
我想要它,这样当用户向 xx.yy 发送请求时,它只会更改显示的主机到同一机器上运行的另一个有效域。
到目前为止我已经做到了(让服务器知道接受来自 xx.yy
的请求):
RewriteCond %{HTTP_HOST} ^.*xx.yy [NC]
RewriteRule ^/(.*)$ http://127.0.0.1:<PORT_OMITTED>%{REQUEST_URI} [P,QSA,L]
RewriteCond %{HTTP_HOST} ^.*mysite.com [NC]
RewriteRule ^/(.*)$ http://127.0.0.1:<PORT_OMITTED>%{REQUEST_URI} [P,QSA,L]
它有效,并且它将流量引导到我的应用程序中,但网址显示 http://xx .yy
当我宁愿它说 http://mysite.com
我知道我可以重定向到 http://mysite.com
而不是 127.0.0.1
,但我有 4 个并行的 mysite.com
盒子,当我已经在这里时,返回 DNS 可能转到另一个盒子似乎是一种浪费。另外,我不确定 POST 请求是如何工作的。
我能做些什么?
Typing out the title to this leads me to believe this might not be possible due to security concerns, but I will ask anyway. I have shortcode support running on my server, lets call it xx.yy
I want it so when a user sends a request to xx.yy
, it just changes the displayed host to another valid domain running on the same box.
I have this so far (lets the server know to accept requests from xx.yy
):
RewriteCond %{HTTP_HOST} ^.*xx.yy [NC]
RewriteRule ^/(.*)$ http://127.0.0.1:<PORT_OMITTED>%{REQUEST_URI} [P,QSA,L]
RewriteCond %{HTTP_HOST} ^.*mysite.com [NC]
RewriteRule ^/(.*)$ http://127.0.0.1:<PORT_OMITTED>%{REQUEST_URI} [P,QSA,L]
It works, and it directs the traffic into my app, but the url says http://xx.yy
when I would rather it say http://mysite.com
I know i could redirect to http://mysite.com
instead of 127.0.0.1
, but I have 4 parallel boxes of mysite.com
and going back out to DNS to maybe go to another box seems like a waste when I am already here. Also, I am not sure how POST requests would work like that.
What can I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果
mysite.com
位于同一个盒子上,并且 DNS 指向那里,只需将R=301
放入[P,QSA,L]
示例
来自 http://www.liewcf.com/redirect-webpages -to-another-domain-538/
除此之外,尽管没有充分的理由去做你所要求的事情。想象一下,如果有人可以链接到 legalwebsite.com,但将其发送到 evilempire.com。
那就太混乱了,就是这样。
If
mysite.com
is on the same box, and DNS is pointing there, just putR=301
in[P,QSA,L]
Example
From http://www.liewcf.com/redirect-webpages-to-another-domain-538/
Other than that, though there's no way for good reasons to do what you are asking. Imagine if someone could link to legitwebsite.com, but have it get sent to evilempire.com.
It'd be chaos, that's what.