0

Currently my website is functioning both with a www prefix and without. I want every page should redirect with www prefix only for search engine optimization (SEO).

The changes should not impact on local development environment (localhost)

How can I do that on Web.Config file?

Any another approaches to accomplish this?

John Conde
  • 217,595
  • 99
  • 455
  • 496
sridharnetha
  • 2,104
  • 8
  • 35
  • 69

1 Answers1

0

I have resolved this problem using the below changes on web.config file.

 <system.webServer>
<rewrite>
  <rules>
    <rule name="Redirect domain.com to www" patternSyntax="ECMAScript" stopProcessing="true">
      <match url=".*" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^mydomain.com$" />
      </conditions>
 <action type="Redirect" url="h t t p : //www.mydomain.com/{R:0}" />
  </rule>
  </rules>
</rewrite>

sridharnetha
  • 2,104
  • 8
  • 35
  • 69