IIS rewrite rule to check for querystring and add it if its not there
Posted
by
M.R.
on Server Fault
See other posts from Server Fault
or by M.R.
Published on 2012-09-29T01:33:38Z
Indexed on
2012/09/29
3:40 UTC
Read the original article
Hit count: 569
I'm trying to make a IIS URL rewrite rule that appends an URL parameter to the URL. The url parameter is hssc
. So, any url that is processed through the server, needs that parameter. Keeping in mind that some urls will have their own params already, and other urls won't, and root urls, etc, sometimes it will need to add ?hssc=1
or &hssc=
- so, if I have a URL that is as such:
- http://www.blah.com should become http://www.blah.com/?hssc=1
- http://www.blah.com/index.html should become http://www.blah.com/index.html?hssc=1
- http://www.blah.com/?q=5 should become http://www.blah.com/q=5&hssc=1
- http://www.blah.com/index.html?q=5 should become http://www.blah.com/index.html?q=5&hssc=1
- http://www.blah.com/index.html?q=5&hssc=1 should be left alone
I also want it that the URL should not be hidden (as in a backend rewrite behind the scenes). I need the URL to appear in the URL, so when users copy the URL, or bookmark it, the parameter is there.
I've set the condition to match it \&hssc|\?hssc
- now I just need a way to write the URL, so it appears and keeps the part of the original URL that is already there.
© Server Fault or respective owner