2012-03-07 7 views
1

안녕하세요, 내 도메인 별칭을 하나의 도메인으로 리디렉션하려고합니다.web.config 여러 도메인을 하나로 리디렉션

나는 현재

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

별칭 나던 앞에 www가있을 때 그것은 완벽하게 작동합니다 ... 내가 리디렉션 말을 어떻게이 모든 것을이 도메인 같지 않은이 규칙을 가지고

감사합니다.

답변

2

사용해보기. 나는 그것이 효과가 있는지 아닌지 모르겠다. 나는이 주제에서 위대하지 못하지만, 여기에 4 개월 동안 대답하지 않은 채로 앉아있다. 그래서 나는 그것을 wollop으로 줄 것이라고 생각했다.

<rule name="Rewrite domain requests" stopProcessing="true"> 
    <match url="(.*)" /> 
    <conditions> 
    <add input="{HTTP_HOST}" pattern="^(www.)?([.a-zA-Z0-9]+)$" /> 
    </conditions> 
    <action type="Rewrite" url="http://www.mydomain.com/url={R:1}" appendQueryString="true" /> 
</rule> 

확실하지 않은 패턴입니다. I 라고 말하면 www가 있는지 여부에 관계없이 URL의 모든 항목과 일치하고 가능한 모든 도메인 확장자를 의미합니다.

+0

저에게 도움이되지 않았습니다. – Zymotik

1

각 도메인에 대해 하나의 규칙을 추가하십시오.

로이드 장 : http://forums.iis.net/t/1185885.aspx

<rule name="Domain Redirect" stopProcessing="true"> 
    <match url="(.*)" /> 
    <action type="Redirect" url="http://{C:1}mydomainalias.com/{R:1}" redirectType="Permanent" /> 
    <conditions> 
    <add input="{HTTP_HOST}" pattern="^(www\.)?mydomain\.com" /> 
    </conditions> 
</rule> 
0

이이 문제를 해결할 너무 쿼리 문자열을 유지합니다. 리디렉션 루프를 피하려면 기본 도메인을 무효화해야합니다.

<rule name="Rewrite domain requests" stopProcessing="true" enabled="true"> 
    <match url="(.*)" /> 
    <conditions> 
    <add input="{HTTP_HOST}" pattern="^(www.)?([.a-zA-Z0-9]+)$" /> 
    <add input="{HTTP_HOST}" pattern="^www\.domain\.com$" negate="true" /> 
    </conditions> 
    <action type="Redirect" url="http://www.domain.com/{R:1}" redirectType="Permanent" appendQueryString="true" /> 
</rule> 
관련 문제