TAGS :Viewed: 13 - Published at: a few seconds ago

[ Aliasing Web Applications in IIS 7.5 ]

I have the need to create aliases for web applications in IIS 7.5.

For example, say I have an application called "MyHappyApp" located at http://server.com/MyHappyApp

I want to create some aliases that redirect to that app such as:

What is the best practice for accomplishing this behavior in IIS 7.5? Please explain where this can be configured in IIS Manager and web.config if possible.

Answer 1

You need to use Rewrite module,

<?xml version="1.0" encoding="UTF-8"?>
                <rule name="MyHappyApp2_To_HappyAppPart3" stopProcessing="true">
                    <match url="MyHappyApp2" ignoreCase="true" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{URL}" pattern="^/$" ignoreCase="true" />
                    <action type="Rewrite" url="/HappyAppPart3" />
            <requestFiltering allowDoubleEscaping="true" />

Answer 2

You need to have the URL Rewrite module installed. You can configure rules through IIS Manager or manually add then to web.config.

Although it's possible to do it all in one rule, it's probably easier to make two seperate rules, one for each alias you want to redirect for.

This should work:

        <clear />
        <rule name="Redirect MyHappyApp2 to MyHappyApp" stopProcessing="true">
            <match url="^MyHappyApp2(/.*)?$" />
            <action type="Redirect" url="http://server.com/MyHappyApp{R:1}" appendQueryString="true" redirectType="Permanent" />
        <rule name="Redirect HappyAppPart3 to MyHappyApp" stopProcessing="true">
            <match url="^HappyAppPart3(/.*)?$" />
            <action type="Redirect" url="http://server.com/MyHappyApp{R:1}" appendQueryString="true" redirectType="Permanent" />

The above rules also support people going to http://server.com/HappyAppPart3/somepage?id=1 (just an example). They will get redirected to http://server.com/MyHappyApp/somepage?id=1.