Learner
Learner

Reputation: 786

301 redirect from one website to another using asp.net web.config file

I have an HTML page in my old website which needs 301 redirect to the aspx page of new website, both websites have been built on asp.net platform. Please suggest me that how could I configure my web.config file to achieve this task. At the moment I am using Meta Refresh to do this, but that is possibly 200 not 301.

Any help would be highly appreciated,Thanks.

I have used following piece of code in my old website web.config file, but it isn't working as well

<configuration>
  <location path="http://example.htm">
    <system.webServer>
      <httpRedirect enabled="true" destination="http://newwebsite.com/test.aspx" httpResponseStatus="Permanent" />
    </system.webServer>
  </location>
</configuration>

Upvotes: 12

Views: 33784

Answers (2)

Kaushik
Kaushik

Reputation: 356

Create rules in your web.config file put

<system.webServer>
    <rewrite>
      <rules>
         <rule name="URL1" stopProcessing="true">
          <match url="^abc.html" ignoreCase="true" />
          <action type="Redirect" url="Your current page path" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
 </system.webServer>

Upvotes: 24

N-ate
N-ate

Reputation: 6943

<configuration>
    <system.webServer>
        <httpRedirect enabled="true" destination="http://uri" httpResponseStatus="Permanent" />
    </system.webServer>
</configuration>

Sorry I don't have a web.config solution for single page. You'll want to place this in your markup page near the top:

<% RedirectPermanent("http://url", true) %>

If it doesn't work for you post your markup here and I'll update it for you.

Upvotes: 4

Related Questions