'IIS URl Rewrite/Redirect - Why is a second question mark being added into into my redirect url?
I am trying to redirect to a URL that has more than one parameter. When the page is redirected to the new URL it is failing because a question mark is being added into the query string of my url that should not be there.
The original URL matches on Search/SearchPage.aspx?search=(.*)
The end part is just a number. I then use that number in my redirect URL which looks like this:
Login.aspx?query=true&doctypegroupid=105&KT158_0_0_0={R:1}
({R:1} is the number from the original URL ex 29987). I don't append the query string and Redirect is permanent.
When I click the original URL it redirects but it gives me a page error. I have determined that it is because the redirect URL is adding an extra question mark like this:
Login.aspx?query=true&doctypegroupid=?105&KT158_0_0_0=29987
I can not figure out why this extra question mark is being added into the URL. This is happening in multiple browsers. Is there something wrong with the way I am doing this? How can I prevent or at the very least ignore this extra question mark?
The question mark gets added even if I hardcode the URL. So If I set the below as the redirect URL and I click the original URL I would get redirected to the below link but with an extra question mark after the second equal sign.
Login.aspx?query=true&doctypegroupid=105&KT158_0_0_0=6278
Solution 1:[1]
I solved it. I had to change the URL I was matching to from Search/SearchPage.aspx?search=(.) to SearchPage.aspx(.).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | peeps3216 |
