How can I use an ampersand (&
) in my url rewrite rules in the web.config file?
I want to rewrite the url:
http://www.foo.com/index.asp?SomeParameter=SomeValue&SomeId=00
to:
http://www.foo.com/Section/Page
I wrote the following rule in my web.config:
<rule name="RuleName" stopProcessing="true">
<match url="^index.asp?SomeParameter=SomeValue&SomeId=00" ignoreCase="true" />
<action type="Redirect" url="Section/Page" appendQueryString="false" />
</rule>
But I'm having problems with that Ampersand (&
) in the input url. When trying to rewrite I Get:
The requested page cannot be accessed because the related configuration data for the page is invalid.
I Tried to parse the ampersand to %26
, but I get the same errror.
The Microsoft URL Rewrite Module 2.0 for IIS 7 and above enables IIS administrators to create powerful customized rules to map request URLs to friendly URLs that are easier for users to remember and easier for search engines to find.
The concept of URL rewriting is simple. When a client sends a request to the Web server for a particular URL, the URL rewriting module analyzes the requested URL and changes it to a different URL on the same server.
Try using the HTML ampersand character code &
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With