URL/Apache 重定向问题。 (域+目录重定向到sudomain)
我已经尝试解决这个问题大约两个小时了。出现了一个新的要求,要求我尝试找到一种方法将请求从 foo.bar.com/blah 发送到 blah.bar.com。
从技术上讲,/blah 并不存在,但我希望在达到这一点之前能够实现服务器重定向。
以前有人必须这样做吗?
解决办法是什么?
I have been trying to figure this out for about 2 hours now. A new requirement came up where it was asked of me to try to find a way to send requests from foo.bar.com/blah to blah.bar.com.
Technically /blah doesn't exist, but I was hoping to have the server redirect before it gets to that point.
Has anyone had to do this before?
What was the solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这个 mod_rewrite 规则:
或者对于任意 URL 路径:
如果您想要不透明的重定向,请通过添加
P
标志 到您的规则。对于永久重定向,请使用R=301
。Try this mod_rewrite rule:
Or for an arbitrary URL path:
If you want an untransparent redirect, use a proxy for the request by adding the
P
flag to your rule. And for a permanent redirect, useR=301
.