2016-07-14 2 views
2

내 사이트가 www.www.sitename.com으로 리디렉션되는 중이 문제가 발생합니다.사이트가 www.www.sitename.com으로 리디렉션됩니다.

나는이 코드를 다른 웹 사이트에서 잘 작동하는 web.config로 작성했습니다.

<system.webServer> 
    <rewrite> 
     <rules> 

     <clear /> 
     <rule name="Redirect to WWW" enabled="true"> 
      <match url="(.*)" /> 
      <conditions> 
      <add input="{HTTP_HOST}" negate="true" pattern="^www\.([.a-zA-Z0-9]+)$" /> 
      </conditions> 
      <action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" /> 
     </rule> 

     </rules> 
    </rewrite> 
    </system.webServer> 

이 100 % wokring 코드를 다른 사이트 있지만이 사이트에 www.www.sitename.com의 문제가 srilanka-tours.co

+0

[URLRewrite] (http://weblogs.asp.net/owscott/url-rewrite-protocol-http-https-in-the-action) –

+0

BTW, 방금 귀하의 srilanka-tours.co 웹 사이트를 방문하여 double-www URL로 리디렉션되지 않았습니다. 재 작성으로 놀고 난 후 브라우저에 캐싱 문제가있을 수 있습니까? –

+1

나에게 보낸 코드를 업데이트 했으므로 잘 작동한다. 하지만 여전히 일반적인 코드로 작동하지 않는 이유를 혼동합니다. –

답변

1

어떻게 덜 일반적이고에 더 집중하고 약 실제 호스트 이름?

예컨대 :

<rule name="Redirect to WWW"> 
    <match url="(.*)" /> 
     <conditions> 
      <add input="{HTTP_HOST}" pattern="^www\.srilanka-tours\.co$" negate="true" /> 
     </conditions> 
     <action type="Redirect" 
       url="http://www.srilanka-tours.co/{R:1}" 
       redirectType="Permanent" /> 
</rule> 

(이 실제 재 작성 규칙에서 발췌 한 것입니다).

위의 규칙은 IIS 관리자의 "마법사"에서 "정식 도메인 이름"을 사용하여 다시 쓰기 규칙을 만드는 것과 비슷합니다. See the article on Scott Guthrie's blog.

+0

(R : 1)과 (R : 0)의 차이점은 무엇입니까? 당신은 (R : 1)을 –

+1

코드에 사용했습니다. 도움을 청합니다. 투어를 업데이트 한 후 사이트가 잘 작동합니다. –

관련 문제