Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rewriting Ampersand URLs with IIS 7 Rewriting Module

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.

like image 606
Pato Avatar asked Aug 17 '11 14:08

Pato


People also ask

Which module is needed by IIS 7 for Permalink by URL rewriting?

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.

How does IIS URL Rewrite work?

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.


1 Answers

Try using the HTML ampersand character code &amp;

like image 149
Lyall Avatar answered Oct 23 '22 23:10

Lyall