M
M
mr_blond972016-03-12 21:16:47
IIS
mr_blond97, 2016-03-12 21:16:47

How to make redirect 301 in IIS?

How to redirect 301 for all paths from www.site to site in IIS?
In the web.config configuration file of the www.site site, I add the following entry:

<configuration>
   <location path="index.html">
    <system.webServer>
    <httpRedirect enabled="true" destination="http://site.com" exactDestination="true" httpResponseStatus="Permanent" />
    </system.webServer>
  </location>
</configuration>

As a result, the redirect only works from www.site/index.html to site/index.html. What changes need to be made to the config so that the redirect works for all paths? And how to check that the 301 redirect is working?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Satisfied IT, 2016-03-13
@mr_blond97

Well, apparently it only works for www.site/index.html because <location path="index.html">
Try it as it says here
Or like this:

<rewrite>
    <rules>
        <rule name="Redirect domain.com to www" patternSyntax="Wildcard" stopProcessing="true">
            <match url="*" />
            <conditions>
                <add input="{HTTP_HOST}" pattern="domain.com" />
            </conditions>
            <action type="Redirect" url="http://www.domain.com/{R:0}" />
        </rule>
    </rules>
</rewrite>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question