2013-05-19 46 views
0

如果指向http://domain.com它重定向到http://www.domain.com/thesite/index.asp這是實際的位置。無論頁面,它總是附加實際的文件夾路徑。Canonical重定向與傳統的ASP顯示網站文件夾

我一直在使用此腳本進行規範重定向,包含在每個頁面中。

If InStr(Request.ServerVariables("SERVER_NAME"),"www") = 0 Then 
    Response.Status="301 Moved Permanently" 
    Response.AddHeader "Location","http://www." &_ 
    Request.ServerVariables("HTTP_HOST")&_ 
    Request.ServerVariables("SCRIPT_NAME") 
End if 

我有一個共享主機的幾個網站,每個網站在自己的文件夾中。

我該如何預防?

thanx您的幫助

回答

1

確定後進一步陷我終於撞到了一個解決方案。原來IIS7已使URL重定向規則,所以這可以通過web.config中我之前忽略它,因爲它被列爲ASP.NET的解決方案,而不是傳統的ASP來完成,像這樣

<configuration> 
<system.webServer> 
    <rewrite> 
    <rules> 
    <rule name="Redirect to WWW" stopProcessing="true"> 
     <match url=".*" /> 
     <conditions> 
     <add input="{HTTP_HOST}" pattern="^yoursite.com$" /> 
     </conditions> 
     <action type="Redirect" url="http://www.yoursite.com/{R:0}" redirectType="Permanent" /> 
    </rule> 
    </rules> 
</rewrite> 

。 但它在那裏,解決了。

相關問題