Peter Nordberg
asked on
Re-direct in IIS
Hi,
I have a question if it's possible to re-direct (re-route) a web request in IIS. For example if a user enters www.mysite.com in the browser I would like it to end up in mysite.com.
Is this possible to do? I'm working in IIS on Windows Server 2012.
Thanks for help!
Peter
I have a question if it's possible to re-direct (re-route) a web request in IIS. For example if a user enters www.mysite.com in the browser I would like it to end up in mysite.com.
Is this possible to do? I'm working in IIS on Windows Server 2012.
Thanks for help!
Peter
ASKER
Hi and thanks for answer,
Where do I set this rule?
Peter
Where do I set this rule?
Peter
You can do this in the web.config in your application:
<system.webServer>
<rewrite>
<rules>
<!-- put <rule> -->
</rules>
</rewrite>
<system.webServer>
<rewrite>
<rules>
<!-- put <rule> -->
</rules>
</rewrite>
ASKER
Hi,
I tried the rule but I got an internal server error. This is how I put it in my web.config:
What can be wrong?
Peter
I tried the rule but I got an internal server error. This is how I put it in my web.config:
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648"/>
</requestFiltering>
</security>
<rewrite>
<rules>
<rule name="Remove www" stopProcessing="true">
<match url="(.*)" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^www\.(.+)$" />
</conditions>
<action type="Redirect" url="http://{C:1}/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
What can be wrong?
Peter
Do you have the re-write module installed on the server?
http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module
http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module
ASKER
I installed it and applied the rule again. This time I got no error but the redirect doesn't seem to take place. If I enter www.kanal10.se it doesn't rewrite it.
Thanks for help!
Peter
Thanks for help!
Peter
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. Worked perfectly!
Peter
Peter
This should work:
Open in new window