Welcome to WebmasterWorld Guest from 23.22.46.195

Forum Moderators: Ocean10000 & incrediBILL & phranque

SetEnvIf Query_String

   
5:55 pm on Jan 13, 2005 (gmt 0)

10+ Year Member



I'm trying to set up a seperate log of adwords-referrers. In my Adword-ads, I apply a "?adwords" to the back of the url, so, requests look like:

[mysite.com...] .

If figured it would be easy to log those, by using SetEnvIf:


SetEnvIf Query_String "adwords" adwords

And make a seperate log that check if env=adwords.

BUT, it doesn't work. The query string is there, it is set in Apache (checked through cgi/perl), but for some reason SetEnvIf cannot access it :-( It tries everything, SetEnvIfNoCase, using Query_String, QUERY_STRING, query_string, "adwords", "^adwords$", "adwords$", but they all fail. Also tried httpd.conf and vhost.conf.

I just cannot get it to work. Anyone here sees what I'm missing or doing wrong? Anyone got something similiar working?

6:26 pm on Jan 13, 2005 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I'm not sure if SetEnvIf can access QUERY_STRING.

You might want to try the method recently described here [webmasterworld.com] using mod_rewrite to set envars.

Jim

8:05 pm on Jan 13, 2005 (gmt 0)

10+ Year Member



Thanks, I currently got this working:


RewriteEngine On

RewriteCond %{QUERY_STRING} adwords$ [NC]
RewriteCond %{ENV:adwords}!^1$
RewriteCond %{HTTP_COOKIE}!^.*adwords=1.*$ [NC]
RewriteRule ^.*$ - [E=adwords:1,CO=adwords:1:www.mysite.com]

RewriteCond %{ENV:adwords}!^1$
RewriteCond %{HTTP_COOKIE} ^.*adwords=1.*$ [NC]
RewriteRule ^.*$ - [E=adwords:1]

However, I believe it is not optimal yet. Not sure if writing out the Cookie through the RewriteEngine is the best thing. Also, the regex for recognizing the adwords=1 in the Cookie is not really efficient.

Anyone got any improvements?

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month