homepage Welcome to WebmasterWorld Guest from
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

Rewrite Rule and affiliate ID problem

 1:07 pm on Jan 7, 2008 (gmt 0)

I finally had my htaccess file running smoothly (thanks to the existing posts here on WebmasterWorld) - when a new problem emerged.

Using the following type of rule I have managed to run the site using SEO friendly URLS:

RewriteRule ^([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/$ /index.php?VAR1=$1&VAR2=$2 [L]

So if someone types in www.mysite.com/foo/bar/ all is fine.

However we have just started an affiliate program and I can't seem to access the affiliate ID in a URL such as:


I'm sure that I need to make an allowance for this somewhere - though I just can't figure what or where. Can someone please shed some light on this?

Thanks for your assistance,



 12:03 am on Jan 8, 2008 (gmt 0)

We'll be needing some examples of the URLs and their corresponding script paths to proceed. ALso, some clarification of "cannot access the aff ID" would be helpful.

What modified rules have you tried with these URLs and what was the result? How did the results differ from your expectations?



 2:19 am on Jan 8, 2008 (gmt 0)

Thanks - I'll dig up some of the testing that I previously tried.

In terms of "cannot access the Affiliate ID" - what I really meant was that if I load the page 'www.mysite.com/foo/bar/?AFF=ID' - the $AFF variable is empty (has no value at all).


 2:41 am on Jan 8, 2008 (gmt 0)

>>$AFF variable is empty

Aside from .htaccess issues, is your new affiliate tracking software working properly? Are orders tracking right?


 2:54 am on Jan 8, 2008 (gmt 0)

No - I'm just beginning to plan the affiliate program and the first step was to look at how I'd pass the variable, set cookies, redirect and so forth.

So all I did was type in an example URL with the?AFF=ID at the end - and was surprised that the variable wasn't available on the page (I've checked by trying to echo the variable as well as getting through get_defined_vars)



 3:13 am on Jan 8, 2008 (gmt 0)

Give QSA (query string append) a try:

RewriteRule ^([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/$ /index.php?VAR1=$1&VAR2=$2 [QSA,L]


 3:15 am on Jan 8, 2008 (gmt 0)

Ah, clearer now. In order to pass the AFF= name/value pair through the RewriteRule where you are passing the VAR1 and VAR2 parameters to /index.php, you will need to use the [QSA] --Query String Append-- flag on the rule. Otherwise, your VAR1/VAR2 parameters will replace the original AFF= query by default.

Merging [QSA] with your existing flag, use [QSA,L].



 7:08 am on Jan 8, 2008 (gmt 0)

Thank you! Worked perfectly.

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