views:

1439

answers:

1

I need to deal with Affiliate Tracking on our website.

In our .htaccess we have:

RewriteCond %{QUERY_STRING} affiliate=(.*)
RewriteRule ^(.*)$ $1?  [NC,R,L,co=AFFID:%1:%{HTTP:Host}:7200:/]

Which creates a COOKIE called AFFID with the value of the URL Parameter affiliate.

But the Cookie is not for the whole domain, i.e. Going to http://www.domain.com/?affiliate=bmk sets the AFFID cookie with the value bmk for .www.domain.com but I would like ti to be for .domain.com so that it can be used across our secure domain which will be secure.domain.com

Any help would be appreciated

Cheers

A: 

Why don't you just hardcode it?

RewriteRule ^(.*)$ $1?  [NC,R,L,co=AFFID:%1:.domain.com:7200:/]

If you can't do that, the you'd have to match the domain, like this (untested):

RewriteCond %{QUERY_STRING} affiliate=(.*)
#This would work only for xxx.dom.com or dom.com forms, not for x.y.dom.com
RewriteCond %{HTTP_HOST} [^.]*?\.?([^.]+\.[^.]+) 
RewriteRule ^(.*)$ $1?  [NC,R,L,co=AFFID:%1:.%2:7200:/]
Vinko Vrsalovic
I tried this but you lose the first match so you only get the domain.I can't hard code due to the environments and multiple domains we have. Glad I was on the right track of thought.
BigMadKev
How come it loses the first match? it's supposed to work... %1 = first match %2 = second match and so on, maybe it is in a different number if you used more captures
Vinko Vrsalovic