2

A customer had their website content in a subfolder on their site e.g. www.customersite.com/content. It has since been moved to the root folder e.g. www.customersite.com

We've added a IIS 301 redirect, to the site config that looks like this:

<rewrite>
  <rules>
   <rule name="Redirect to Root" stopProcessing="true">
     <match url=".*" />
       <conditions>
        <add input="{HTTP_HOST}" pattern="^customersite.com/content/$" />
       </conditions>
      <action type="Redirect" url="http://www.customersite.com/{R:0}"
        redirectType="Permanent" />
   </rule>
  </rules>
</rewrite>

The site had links that looked like www.customersite.com/content/?p=12 would it be possible to change the redirect to automatically redirect to www.customersite.com/?p=12 if a user types in the old www.customersite.com/content/?p=12 address? If so how?

Thank you!

PW763
  • 251
  • 1
  • 6
  • 12

2 Answers2

3

I'm not able to test it right now, but this should work:

<rewrite>
  <rules>
   <rule name="Redirect to Root" stopProcessing="true">
     <match url="^content/(.*)" />
       <conditions>
        <add input="{HTTP_HOST}" pattern="^(www\.)?customersite.com$" />
       </conditions>
      <action type="Redirect" url="http://{C:0}/{R:1}" redirectType="Permanent" />
   </rule>
  </rules>
</rewrite>
Marco Miltenburg
  • 6,123
  • 1
  • 29
  • 29
0

Any file which is www.customersite.com/content/?p=12 will actually be one of the default pages in IIS, so the page will really be something like www.customersite.com/content/index.aspx?p=12 assuming your default file is index.aspx it could be default etc.

Just add a file at this location and set the code behind to take the query string and do a redirect, you can also change the header state from the code behind to show this is a 301.

TheAlbear
  • 5,507
  • 8
  • 51
  • 84