...

View Full Version : htaccess for passing Google gclid parameters



jbschwartz
05-25-2011, 11:04 PM
Hi Folks.

I'm just not understanding how to do what has to be done to get Google Adword's gclid parameters to pass upon redirect on a website.

Normally, users who arrive like this:
www.MyDomain.com
...are seeing the default page:
www.MyDomain.com/index.php

The Google Adword users are arriving like this:
www.myDomain.com?gclid=12345
...but the "gclid=12345" is being lost and users are seeing:
www.MyDomain.com/index.php

So...what do I need to do to keep the "gclid" parameter intact , like this:
www.MyDomain.com/index.php?gclid=12345

In this case, I need to execute this with a .htaccess file.

Thanks in advance.

Inigoesdr
05-26-2011, 01:28 AM
Are you redirecting the request to index.php? If so you just need to add the [QSA] flag to your RewriteRule.

jbschwartz
05-26-2011, 03:11 PM
Are you redirecting the request to index.php? If so you just need to add the [QSA] flag to your RewriteRule.

I am, but I have no .htaccess file with rules at all yet. I'm starting from scratch.

J

Inigoesdr
05-26-2011, 03:36 PM
How are you redirecting the page then? In PHP?

jbschwartz
05-26-2011, 04:16 PM
How are you redirecting the page then? In PHP?

Pardon the ignorance.

I'm not exactly sure of the current mechanism. The site is hosted at Hostway, a third party. I assume that URLS that arrive to the site without a page in the address are automatically translated to index.php. It is running Linux/Apache.

For reference, I am familiar with the mechanism in Mac OS X Server, but not at this hosting company.

HTH

J

Inigoesdr
05-26-2011, 05:18 PM
Just to be clear, you're saying you go to "www.myDomain.com?gclid=12345" and the URL changes to "www.MyDomain.com/index.php" correct? If that's the case you need to find out what is causing the redirection and alter it to append the query string or preemptively redirect the user with a rewrite when it contains the gclid.

jbschwartz
05-26-2011, 07:34 PM
Just to be clear, you're saying you go to "www.myDomain.com?gclid=12345" and the URL changes to "www.MyDomain.com/index.php" correct? If that's the case you need to find out what is causing the redirection and alter it to append the query string or preemptively redirect the user with a rewrite when it contains the gclid.

You describe the situation correctly.

It is the latter I am attempting to do to resolve the issue (create a rewrite rule using .htaccess). This is what the tech folks at Hostway recommended. I don't believe I have access to the mechanism that is stripping the query string.

So...we're back to the original question: how to create the htaccess rule.

Thanks for your continued help.

J

jbschwartz
05-26-2011, 09:46 PM
Ok. I took a shot. Here's my attempt...which doesn't work...

RewriteEngine on <br>
RewriteRule ^www.mydomain.com?gclid= index.php [QSA]

jbschwartz
05-26-2011, 10:24 PM
Here's another try...


RewriteEngine on <br>
RewriteRule ^http://www.mydomain.com/?gclid= http://www.mydomain.com/index.php [QSA]


Looking for end result where the gclid parameter is passed through instead of being stripped.

Inigoesdr
05-27-2011, 01:29 AM
Try something like this:

RewriteEngine On
RewriteCond %{QUERY_STRING} gclid
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.*)$ /index.php [R=301,QSA]

jbschwartz
05-27-2011, 02:29 AM
Try something like this:

RewriteEngine On
RewriteCond %{QUERY_STRING} gclid
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.*)$ /index.php [R=301,QSA]

Wow! That worked exactly as desired! Thanks!

Where do I donate?

Jonathan



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum