Forum Moderators: phranque
I'm developing a site and don't have access to the .conf file nor do I have the option to use .shtml pages nor do I have the option to use cookies.
All I've got to work with is the .htaccess file.
The client's affiliates are sending traffic in via a link that looks like:
[clientsite.com?src=affiliatename...]
This does a fine job, and loads the client's index.html page. Happyville, so far.
Now, when the visitor surfs through the site to a second page, call it page2.html, I want to make the URL in the browser look like
[clientsite.com...]
I know that I'll need...
RewriteCond %{HTTP_REFERER}!^.*?src=.*$ [NC]
RewriteRule ^(.*)$ $1?src=none [L]
... in order to append in cases where the URL is typed in, i.e. no refering link.
BUT, then what?
I thought first about doing...
RewriteCond %{HTTP_REFERER} ^.*?src=.*$ [NC]
RewriteRule ^(.*)$ $1?%{HTTP_REFERER} [L]
RewriteRule ^(.*)\?.*\?(.*)$ $1?$2
... but it didn't seem to work.
I don't know if my syntax is bad, if you can't use an environment variable in that context or if this sort of chaining is illegal.
Can anyone put me straight on this? I'd be much obliged.
Welcome to WebmasterWorld [webmasterworld.com]!
If you want the browser to show the affiliate in order to "carry" the affiliate info throughout the user's "session" then you'll need to use an external redirect:
RewriteCond %{HTTP_REFERER} \?src=(.*)$ [NC]
RewriteRule ^(.*)$ $1?src=%1 [R=301,L]
Have you considered setting up wildcard subdomains? That would allow you to put the affiliate at the front end of the URL, and all of your internal site links would remain unchanged.
Jim