Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS URL Rewrite for redirect to FQDN

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?

like image 584
Karthik Murugesan Avatar asked Aug 02 '13 00:08

Karthik Murugesan


People also ask

How do I fix the URL Rewrite module in IIS?

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.

What is the difference between URL Rewrite and redirect?

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.


1 Answers

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).

like image 60
cheesemacfly Avatar answered Sep 20 '22 11:09

cheesemacfly