views:

25

answers:

2

Say I have the following .htaccess file:

RewriteEngine On

RewriteCond %{HTTP_COOKIE} name=value [NC]
RewriteRule ^image01.gif$ http://www.domain.tld/images/partner/image01.gif [NC,QSA]

RewriteCond %{HTTP_COOKIE} name=value [NC]
RewriteRule ^image02.gif$ http://www.domain.tld/images/partner/image02.gif [NC,QSA]

What do NC and QSA mean?

Also, instead of repeating the same RewriteCond twice is there to use it just once and have it apply to both RewriteRules?

Finally, if the above .htaccess is located at http://www.domain.tld/images/ why doesn't a RewriteRule like this work?:

RewriteRule ^image02.gif$ /images/partner/image02.gif [NC,QSA]

Or maybe this?:

RewriteRule ^image02.gif$ partner/image02.gif [NC,QSA]

A: 

NC is for No Case, meaning it can be upper or lower case and it will take you to the same page.

QSA is for query string append. Not really sure on this one, however a quick search http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html sheds a bit more light on this one.

imbadatjquery
A: 

The square bracket options are documented in the RewriteRule manual page:

'nocase|NC' (no case):

This makes the Pattern case-insensitive, ignoring difference between 'A-Z' and 'a-z' when Pattern is matched against the current URL.

'qsappend|QSA' (query string append):

This flag forces the rewrite engine to append a query string part of the substitution string to the existing string, instead of replacing it. Use this when you want to add more data to the query string via a rewrite rule.


As far as I know, the RewriteCond directives affect the RewriteRule they precede. If you were setting rules in the main confing file you could write the common directives in a file and include it several times but that's not an option in .htaccess files, sorry.


Your directive works for me, although you probably mean this:

RewriteRule ^image02\.gif$ /images/partner/image02.gif [NC,QSA]

How are you testing it exactly?

Álvaro G. Vicario