簡體   English   中英

Web.Config 301重定向

[英]Web.Config 301 Redirect

我正在嘗試將特定頁面從舊域重定向到新域中的特定頁面。 URL如下所示:

http://blog.mysite.com/post/2012/05/hungry.aspx

http://mynewsite.com/hungry.aspx

我查看了Web.Config文件進行此更改,但是以下代碼不起作用:

<location path="post/2012/05/hungry.aspx">
    <system.webServer>
      <httpRedirect enabled="true" destination="http://mynewsite.com/hungry.aspx" httpResponseStatus="Permanent" />
    </system.webServer>
  </location>

當我訪問舊博客頁面時,它不會重定向,並保留在舊博客頁面上。

我想念什么嗎?

如果在舊服務器上啟用了HTTP重定向,那么您必須將新的Web配置放入此內容的post / 2012/05 /文件夾中

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpRedirect enabled="true" destination="http://mynewsite.com/" httpResponseStatus="Permanent" />
    </system.webServer>
</configuration>

順便說一句 如果所有其他選項均失敗,則可以使用后面的代碼使用Response.Redirect進行操作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM