[英]Permanent 301 redirect for ASP.NET IIS7
我試圖弄清楚如何為放置在Microsoft-IIS / 7.0類型服務器上的網站設置301永久重定向。 假設我有一個域名www.A.com,並且我想將其重定向到www.B.com,我可以在web.config文件中使用類似以下內容的東西:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to WWW" stopProcessing="true">
<match url="A.com" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.B.com$" />
</conditions>
<action type="Redirect" url="http://www.B.com/{R:0}"
redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
將web.config放在根目錄中時,服務器將響應:
403-禁止訪問:拒絕訪問。 您無權使用您提供的憑據查看此目錄或頁面。
任何建議為什么會給出此403錯誤?
提前致謝。
如果使用普通(默認)web.config和完全香草的Default.aspx收到403錯誤,則IIS存在配置問題。 應用程序池很可能無權訪問網站的基本文件夾。 聽起來您處於托管狀態,請與系統管理員聯系。
這應該有效並且也更簡單。 您不需要URL重寫,只需HTTP重定向。
至於403,IIS應用程序池是否對站點根目錄的文件夾具有讀取權限?
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpRedirect enabled="true" destination="www.B.com" httpResponseStatus="Permanent" />
</system.webServer>
</configuration>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.