davidejones
davidejones

Reputation: 1949

how to append query string based on referrer using htaccess rewrite rule

Ok so i'm trying to come up with some rewrite rules in Iirf.ini and i can't quite get it. I'm looking to check the referrer and then add something to the querystring of url you are hitting

1.so say i came from testing.lc and hit just the domain

domain.com/

2.or the domain with index.cfm

domain.com/index.cfm

3.or the domain with index.cfm and any number of query params

domain.com/index.cfm?key1=value1&key2=value2

4.or the domain with a shorturl

domain.com/login

5.or the domain with a shorturl and any number of query params

    domain.com/login?key1=value1

domain.com/page?key1=value1

So far i have something like this

RewriteCond %{HTTP_REFERER} ^http://testing\.lc/.*$
RewriteRule ^/([^?]+)(\?.*|/){0,1}$ /$1?newkey=newvalue [I,QSA]

Which appears to work on a few urls but not all of those listed above. This rewrite cannot use [L] either as there are other matches after for the urls such as /login that need to pass the querystring.

Any help or advice greatly appreciated...

Upvotes: 1

Views: 577

Answers (0)

Related Questions