homepage Welcome to WebmasterWorld Guest from 54.226.21.57
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
SetEnvIf Query_String
Orange_XL

10+ Year Member



 
Msg#: 2638 posted 5:55 pm on Jan 13, 2005 (gmt 0)

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?

 

jdMorgan

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



 
Msg#: 2638 posted 6:26 pm on Jan 13, 2005 (gmt 0)

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

Orange_XL

10+ Year Member



 
Msg#: 2638 posted 8:05 pm on Jan 13, 2005 (gmt 0)

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?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved