This article is a spin-off from a Microsoft TechNet article I had recently published called Search Service Application Issue with AAM.  In this article I am going to focus on how you can re-direct incomplete URLs to the correct URL of your choice. The steps provided in this article works for both anonymous access sites and those that require authentication.

Setting the scene

You have a site built on an on-premise SharePoint farm. The primary URL of this site is Thanks to Alternate Access Mapping and IIS bindings you can now access this site as or where all the components such as the custom designed master page, search, taxonomy term, ETC, works without any issues.

Below is a screenshot of the  AAM settings on SharePoint Central Administration (CA).


Below is a screenshot of the  IIS bindings we have currently setup.

Below are the screenshots of accessing the same site using different URLS



What is the problem?

If you type in and hit enter, thanks to most browser's autocomplete functionality, the URL automatically populates as and then you receive the below error.


 What caused this to happen?

Although there could be several reasons which caused this issue, the most common reason I have come across is the host header URL added when a web application was built. If you typed in a specific URL when building a web application, that URL automatically becomes the default binding in the IIS. Now you need to manually add other possible bindings to your web application.

How to resolve this issue?

Two changes need to be made, one in IIS Manager and the other in the Web.config file. If you have web front end servers then you need to make the changes there.

Changes in IIS Manager

Below are the steps to make the changes to sites in IIS Manager. As an added precaution I have even added a binding for the company's domain name just in case an external user happens to type that in aswell.
 1. Go to IIS Manager>Select the site of your choice and then click on Bindings as shown below.
 2. Add the bindings of your choice. Below are the bindings that will be added.
  a. (This was originally added when the web application was made)
  b. (This was added for AAM)
  c. (This is the new binding for re-direct)
  d. (This is the new binding for re-direct)

Below is a screenshot of all the bindings add to the site on IIS Manager.  As a side note, if you have several web front end  (WFE) servers then its best to pick the IP address when you are adding bindings.


Adding the above binding itself isn't enough because if you try accessing the site with and you will get the below error. Below are screenshots



Changes in Web.Config file.

Make a copy of the web.config file and save it before making any changes to it.
You can either do a URL rewrite directly on the Web.config file or download and install the URL Rewrite 2.0 extension from This installation does not require a reboot. Below is the added IIS feature once you have the URL Rewrite installed.

In this article I am going to show you how to make changes to the Web.config file and URL Rewrite.

Make changes directly on the Web.config file

In the below screenshot I have provided the location where the web.config file is located for this web application.


You can use notepad to open and make changes to the web.config file.
Look for the <handlers>….</handlers> code in the config file. If your web.config file hasn't been edited before then it should look something like this.

Right below the </handlers> added the below code.

                <rule name="RedirectSiteURLRule1">
                    <match url="(.*)" />
                        <add input="{HTTP_HOST}" pattern="^www\.domain\.com$" negate="true" />
                    <action type="Redirect" url="}" />

Make changes using URL Rewrite.

Double click on URL Rewrite


On the top right under Actions click on 'Add Rule(s)…'


Select 'Canonical domain name'


Choose the URL that you want all the end users to be re-directed to.  In my case it was Click OK.

You will be redirected back to URL Rewrite and below is what you should see.

We are now going to test it.  Double-click the rule you just created and click on 'Test pattern…' as shown below

In 'Input data to test:' type in one of the bindings you added. I my case I typed in Click on 'Test' If the test is successfully then below are the results you should see.

Below is the results for testing


Once you have made changes using the web.config file or using URL rewrite, open a browser and try accessing both and
Even thought the URL on the browser is, the authentication windows shows Below is a screenshot.

The same for


After you have typed in the username and password, below is the URL on the browser i.e. the URL we want the end users to use.



The steps described above are simple and straight forward, however, it is absolutely imperative that you do not miss a step.

If you have already setup all your taxonomy terms and search using a specific URL then I highly recommend using this re-direct approach. Its easier to force the end users to access the URL you want them to than rebuilt the configuration.