0

I'm trying to rewrite all the urls for my website. For example, if the user types in mysite.com/index.aspx it'll change the url in the top to www.mysite.com/index.aspx

Any suggestions?

Hani Honey
  • 2,101
  • 11
  • 48
  • 76

1 Answers1

0

Try this one

<rewrite>
    <rules>
        <rule name="Enforce canonical hostname" stopProcessing="true">
            <match url="(.*)" />
            <conditions>
                <add input="{HTTP_HOST}" negate="true" pattern="^www\.mysite\.com$" />
            </conditions>
            <action type="Redirect" url="http://www.mysite.com/{R:1}" redirectType="Permanent" />
        </rule>
    </rules>
</rewrite>
Vangelis
  • 139
  • 10
  • Where would I put this piece of code? I was using IIS Manager for most of my rewrites/redirects. – Hani Honey Nov 11 '11 at 15:27
  • The rewrite rules are stored either in the ApplicationHost.config file or in Web.config files. Open a Web.config file located in %SystemDrive%\inetput\wwwroot\ – Vangelis Nov 11 '11 at 15:37