简体   繁体   English

301我如何重定向到主页?

[英]how do i 301 Redirect to home page?

i want to redirect one of my pages in my website to home page with using Web.config. 我想使用Web.config将我网站中的页面之一重定向到主页。 I used this but it does not work. 我使用了它,但是它不起作用。

<system.webServer>
    <rewrite>
      <rules>
        <rule name="URL1" stopProcessing="true">
          <match url="http://www.mywebsite.com/unnecessary-page" ignoreCase="true" />
          <action type="Redirect" url="http://www.mywebsite.com/" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>

There is two type of problems might you have: 您可能会遇到两种类型的问题:

  1. You need to install rewrite module if you have 500 error. 如果出现500错误,则需要安装重写模块
  2. You should not use domain in your URL. 您不应在URL中使用域。
<rewrite>
  <rules>
    <rule name="URL1" stopProcessing="true">
      <match url="unnecessary-page" ignoreCase="true" />
      <action type="Redirect" url="/" redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>

I have tested this code and it works fine for me. 我已经测试了这段代码,对我来说很好用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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