IIS Redirect

What is the best way to redirect ex.domain.com/ex  to just ex.domain.com?
PDISAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dan McFaddenSystems EngineerCommented:
Installing and using URL Rewrite.

Reference link:  http://www.iis.net/downloads/microsoft/url-rewrite

Dan
0
PDISAuthor Commented:
That tells me what URL Rewrite is but does not explain how to write one for what I need.
0
Dan McFaddenSystems EngineerCommented:
Insert the following structure into your web.config under the <configuration/system.webServer> section:

If the <system.webServer> section exists, add this under/in the <system.webServer> section:
        <rewrite>
            <rules>
                <rule name="Redirect /ex to /" stopProcessing="true">
                    <match url="^(ex).*" />
                    <action type="Redirect" url="/index.html" />
                </rule>
            </rules>
        </rewrite>

Open in new window


If the <system.webServer> section does not exist, add this under the <configuration> section :
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Redirect /ex to /" stopProcessing="true">
                    <match url="^(ex).*" />
                    <action type="Redirect" url="/" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>

Open in new window


You can also create and add the redirect rule in the IIS Manager.
1. open IIS Manager
2. go to the website where you want to add the redirect
3. double click on the URL Rewrite feature
4. Click "Add Rule(s)" under the Actions section on the right hand site of the IIS Manager
5. The rule should be created as in the image below:

IIS8-redirect-ex-folder-to-root--web-pag
Dan
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft IIS Web Server

From novice to tech pro — start learning today.