Redirect 301 with web.config

Asked

Viewed 260 times

0

I’m updating a website, and the Urls will change. So, I need to make a redirect 301 with web.config, but I couldn’t. Below the code I built:

<configuration>
    <location path="site-antigo">
        <system.webServer>
            <httpRedirect enabled="true" destination="site-novo" httpResponseStatus="Permanent" />
        </system.webServer>
    </location>
</configuration>

What I hoped would happen with this code:

When accessing the page http://meusite.com.br/site-antigo the user would be redirected to http://meusite.com.br/site-novo, but this isn’t happening. I’m doing something wrong?

1 answer

0


In this case you should use the url rewrite module.

<rewrite>
  <rules>
    <rule name="Redirect from blog">
      <match url="^site-antigo" />
      <action type="Redirect" url="site-novo" redirectType="Found" />
    </rule>
  </rules>
</rewrite>
  • But does it have the same effect as a 301 redirect? Google understands this?

  • According to the documentation, yes. But I suggest to confirm in the browser console, as it will depend on the settings made. Use IIS Manager tb can be very useful :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.