Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS Web.Config 301 Redirect on Query String Parameter (?)

    <rule name="blog" stopProcessing="true">
      <match url="en/blog.aspx?Id=9" />
      <action type="Redirect" url="http://www.mynewurl.com" redirectType="Permanent" />
    </rule>

I can redirect "en/blog.aspx" but I am unable to redirect only "en/blog.aspx?Id=9".

Any Ideas?

like image 470
Etienne Dupuis Avatar asked Jun 14 '12 18:06

Etienne Dupuis


1 Answers

Finally found the solution:

/en/blog.aspx?Id=9 will redirect to http://www.newurl.com.

    <rule name="blog" stopProcessing="true">
      <match url="en/blog.aspx$" />
      <conditions>  
        <add input="{QUERY_STRING}" pattern="Id=9" />  
    </conditions>  
      <action type="Redirect" url="http://www.newurl.com" redirectType="Permanent" />
    </rule>

Found the solution here : 301 redirect not working in IIS 7

like image 198
Etienne Dupuis Avatar answered Oct 16 '22 10:10

Etienne Dupuis