Welcome to WebmasterWorld Guest from 23.22.79.235

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Stripping the QUERY_STRING

Removing unsightly AdWords string

   
3:46 am on Oct 29, 2003 (gmt 0)



I have recently started adding a query string to my adwords campaigns for tracking and I was hoping for this to show up in my logs (at least on the first pass) but then be removed prior to displaying the actual page.

I thought of using mod-rewrite but I guessed that that's only for rewriting the host/filename stuff.... but then I found:

When you want to erase an existing query string, end the substitution string with just the question mark.

So I tried the following but alas to no avail:

RewriteCond %{QUERY_STRING} ^gad=foo
RewriteRule (.*) http://%{HTTP_HOST}/$1/? [R=302,L]

Two questions:
1) is this possible (and where's my mistake - the 302's meant to be inoccuous and the L is there so it loops); and
2) perhaps more importantly - by stripping off the string will I ever see it in the logs (I was hoping that it would show up in the first pass and then disappear for the display and then the remainder of the logs).

I do not (yet) have my own weblog software so I was simply going to use Grep for windows to get an idea of adwords traffic.

I guess therefore - the fourth of my two questions (!) is - any better ideas for a simple analysis of adwords (but then I guess that's another forum). I'm still curious about my mod-rewrite problem though :)

4:01 am on Oct 29, 2003 (gmt 0)

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



bpresent,

The code you posted should work. But I seem to recall running into problems when trying to use server variables in the substitution in .htaccess. Try this slight modification to see if that's the problem:


RewriteCond %{QUERY_STRING} ^gad=foo
RewriteCond %{HTTP_HOST} ^(.*)$
RewriteRule ^(.*)$ http://%1/$1/? [R=302,L]

Jim
4:38 am on Oct 29, 2003 (gmt 0)



Hi Jim,

Thanks - actually it did work (sort of) - must've been a caching hiccup of some sort.

It put an extra slash on the end though so:


RewriteCond %{QUERY_STRING} ^gad=foo
RewriteRule (.*) http://%{HTTP_HOST}/$1? [R=302,L]

...does work BUT - alas it strips it before anything appears in my log.... I'm off to the Adwords forum I guess :)