使用 apache 配置上的查询字符串设置引用标头 [英] set referrer header using query string on apache configuration

查看:26
本文介绍了使用 apache 配置上的查询字符串设置引用标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从查询字符串中获取一个参数并将其设置在 Apache 配置文件的引用标头中.你知道这是否可能?

I need to take a parameter from the query string and set it in the referrer header in the Apache configuration file. Do you know if this is possible?

我可以对 cookie 做同样的事情,但我需要使用查询字符串来做.

I'm able to do the same with the cookies but I need to do it using the query string.

setEnvIfNoCase ^Cookie$ "(referrer=\w*:\/\/\w*)" HTTP_MY_COOKIE=$1
setEnvIfNoCase HTTP_MY_COOKIE "(http:\/\/.*\.\w*)" REFERRER=$1
RequestHeader set Referer %{REFERRER}e

问候

推荐答案

解决方案非常简单.setEnvIfNoCase 或 setEnvIf 无法使用查询字符串,因此无法使用我用于 cookie 的相同技巧,解决方案是将 RewriteCond 与 RewriteRule 结合使用,如下例所示:

The solution was quite simple. setEnvIfNoCase or setEnvIf can't use the query string so is not possible to use the same trick i used for the cookies, the solution is a combination of RewriteCond with RewriteRule like in the example below:

RewriteCond %{QUERY_STRING} referrer=(.*)
RewriteRule ^/ - [env=REFERRER:%1]
RequestHeader set Referer %{REFERRER}e

我回答了我的问题,以便其他有相同问题的用户(如果存在)可以找到起点.

i answered to my question so another user (if exist) with the same question can find an starting point.

这篇关于使用 apache 配置上的查询字符串设置引用标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆