Do you have any other lines to the .htaccess file that might have bad flags? Can you paste the contents of the .htaccess file here. If you have problems posting urls due to ozzu's spam filters put parenthesis around the periods such as this:

www(.)yoursite(.)com

joebert

Fart Bubbles

Posts: 13506

Loc: Florida

3+ Months Ago

Reading through your guys posts here, a few things stand out for me.

1) If you rewrite away your affiliatecode querystring variable, how are you going to track it ?

2) [pattern matching for] RewriteRule doesn't see the protocol, host, or querystring last I knew. It only sees the URI (everything between ".co.uk/" and "?variable..."). You would need to use RewriteCond with the corosponding %{VARIABLE_NAME} to work with any of them.

3) Have you read this ?

// Edit -- Clarified #2 in light of what part of RewriteRule works with the querystring

Bigwebmaster

Site Admin

Posts: 9117

Loc: Seattle, WA & Phoenix, AZ

3+ Months Ago

I believe by default the RewriteRule does not see the querystring, but if you use the QSA flag it does:

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

Quote:

Modifying the Query String

By default, the query string is passed through unchanged. You can, however, create URLs in the substitution string containing a query string part. Simply use a question mark inside the substitution string to indicate that the following text should be re-injected into the query string. When you want to erase an existing query string, end the substitution string with just a question mark. To combine new and old query strings, use the [QSA] flag.

And here for 1.3 users:

http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

Quote:

'qsappend|QSA' (query string append)This flag forces the rewriting engine to append a query string part in the substitution string to the existing one instead of replacing it. Use this when you want to add more data to the query string via a rewrite rule.

Edit*

After re-reading what Joebert wrote I think the QSA flag can be used with the rewrite rule, but only for the rewriting part such as changing or adding new variables to the query string. I think Joebert may be right in the fact that you can't actually match the query string without using a RewriteCond first.

joebert

Fart Bubbles

Posts: 13506

Loc: Florida

3+ Months Ago

I should have been more specific. The first argument, or pattern matching section, of the RewriteRule directive doesn't see the querystring.

The QSA, or Query String Append flag relates to the second argument of the RewriteRule directive, or the replacement section. The flag is only really relevant when your replacement string includes a querystring itself.

Considering the following example URL. I've only included the elements you're commonly going to see in a URL.

Right off the bat, mod_rewrite never knows #hash even exists. Browsers don't send that portion to the server, ever. It was designed for navigation within the page, so it didn't make sense to implementers to have "irrelevant" information sent across the network.

mod_rewrite can see everything else in the URL, but not all of it is used when mod_rewrite tries to match a pattern against it with a RewriteRule.

Here's an example combination of mod_rewrite directives that will work with the entire example URL.

The last 301 is an example of a affiliate (longbeach) whose URL redirects to the tracking URL, but really I want this to go to our homepage, but still track it. I was thinking I'd need to have 2 301s for each affiliate, one redirecting a nice URL to the tracking URL with query string, and one directing this to the normal homepage of our site. I'm not even sure if it's possible.

joebert

Fart Bubbles

Posts: 13506

Loc: Florida

3+ Months Ago

You can think of mod_rewrite as a way to alter the address your user is asking for before your server is asked for it. It's a lot like standing right behind the user while they type an address and correcting them if they type "sutff" instead of "stuff".

Now technically, the request has gotten to the server when mod_rewrite works with it, so really it's more like standing behind someone at a night club and correcting them if they begin to say their nickname instead of the name the bouncer will actually find on the list.

All mod_rewrite does is handle aliases. Any querystring variables that aren't included in the result URL are thrown away, the server never knows they existed.

In our bouncer scenario this would be like coming to the door and before saying their name is "slick rick" you correct them to "rick" and the bouncer checks the list for "rick". After rick gets inside the door he is from there on reffered to as "rick" and not "slick rick" because the bouncer gave him a name tag with just plain "rick" on it. Rick has also miraculously forgotten he was once referred to as "slick rick".

--

What you'll need to do is setup your 301 redirects for your affiliates to a logging script with their affiliate id attached. Within that script you will handle your affiliate logging, and place the affiliate id in a session and send a session cookie along with a second 301 redirect request from within the script.

--

So basically, you're not going to use mod_rewrites RewriteRule or RewriteCond at all to accomplish what you need to do.

caravan5

Novice

Posts: 20

3+ Months Ago

Thanks, Joebert and Bigwebmaster, I'll post a request for help in the programming forum when I get my head around it!