Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 911
Learner Avatar asked Jul 04 '14 02:07

Learner


2 Answers

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>
like image 112
Kaushik Avatar answered Nov 10 '22 07:11

Kaushik


<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.

like image 4
N-ate Avatar answered Nov 10 '22 07:11

N-ate