문제

If pointed to http://domain.com it redirects to http://www.domain.com/thesite/index.asp which is the actual location. No matter the page, it always appends the actual folder path.

ive been using this script for canonical redirection, included in every page.

 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

I have several sites in a shared hosting, each in its own folder.

How can i prevent this?

Thanx for your help

도움이 되었습니까?

해결책

Ok after further diggin' i finally bumped into a solution. Turns out IIS7 had url redirection rules enabled, so this can be accomplished through web.config, like this

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

I overlooked it before cause it was listed as ASP.NET solution, not classic ASP. But there it is, solved.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top