I am trying to figure out the best URL rewrite rule to accomplish the following.
http://intranet/sites/default.aspx rewrite to http://intranet.domain.com/sites/default.aspx
http://intranet rewrite to http://intranet.domain.com
Also in IIS the URL binding is set to "intranet" for that web application
Hope that makes sense. Can someone please help with the rewrite rule?
IIS Rewrite Module ProblemUninstall the Rewrite Module from Windows Features. Go to the Web Platform Installer. Pick Url Rewrite from Products | Server section and install. Restart IIS.
Simply put, a redirect is a client-side request to have the web browser go to another URL. This means that the URL that you see in the browser will update to the new URL. A rewrite is a server-side rewrite of the URL before it's fully processed by IIS.
This is the rule I would use:
<rule name="Intranet redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^intranet$" />
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="http://intranet.domain.com/{R:0}" />
</rule>
It will match any requested path (url="(.*)"
) on the host exactly named http://intranet
(pattern="^intranet$"
and with https
been turned off) and redirect it to http://intranet.domain.com/{R:0}
(where {R:0}
is a back reference containing whatever path was requested).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With