문제

Currently both http://example.com and http://www.example.com works fine. However we need to make all http://example.com urls to be redirected to http://www.example.com.

The site is an ASP.net MVC4 website. To get it done I have added the following web.config entry under System.webserver.

<httpRedirect enabled="true" destination="http://www.example.com" />

However it is resulted in a redirect loop. Can you please help me get this done.

도움이 되었습니까?

해결책

Try Adding this to web.config. There must be rewrite module installed in your IIS. Read this Article for better explanation.

<rewrite>
    <rules>
        <rule name="Redirect domain.com to www" patternSyntax="Wildcard" stopProcessing="true">
            <match url="*" />
            <conditions>
                <add input="{HTTP_HOST}" pattern="domain.com" />
            </conditions>
            <action type="Redirect" url="http://www.domain.com/{R:0}" />
        </rule>
    </rules>
</rewrite>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top