是否可以使用 mod_rewrite 仅从 HTTP_REFERER 获取主机名?
我试图仅从 Apache 服务器变量 HTTP_REFERER 解析主机名,我想知道 mod_rewrite 是否可以,因为我的目标是获取主机名,然后重写请求。
I'm trying to parse hostname only from the Apache server variable HTTP_REFERER and I'm wondering if it's possible with mod_rewrite since my goal is to obtain the hostname and then rewrite the request.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的 HTTP_REFERER 将返回链接到你的页面的确切 URL,无论是否使用 mode_rewrite,它都会返回文字 url。因此,如果是 something.com/foo/index.php 或 somthing.com/foo/action,http_referer 将像显示的那样捕获这些 url。
Your HTTP_REFERER will return the exactly URL that linked to your page, with mode_rewrite or not, it will return the literal url. So, if it is something.com/foo/index.php or somthing.com/foo/action, the http_referer will cat these urls like as appear.
我想通了
通过 RewriteCond 的反向引用,我可以将查询字符串附加到新的路径/URL 中。
I figured it out
With the back-reference from RewriteCond, I can append the query string to the new path/URL.