简体   繁体   中英

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>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM