I’m baaaaackkkkkkk,  lol.   I apologize for taking about a 6 month break but I’m back and will have some new fresh blog content starting now.   I recently ran into an interesting scenario with a request to change the Host Header URL of a web application in SharePoint 2010.   I was surprised that I didn’t find much out on TechNet or any Microsoft publications on how to accomplish this properly for SharePoint 2010 which is the purpose of this blog.  First, let’s describe what it means to create a host header web application.   When you create a web application you have the ability to add a host header url.

initialcreate

 

In the above screenshot, I created a web application with a host header URL of RussMaxOriginalHost.   After creating the web application and site collection, I browse to the IIS Site and look at the bindings and the Host Header is added automatically which is expected.

image

 

Also, If I check Alternate Access Mappings in Central Admin I see the default zone is populated with my host header URL for the given web application

image

 

And finally, browsing to the site after creating the site collection renders the site with the specified host header.

image

 

What happens when I need to change this host header URL value?   My original thought was to simply go edit the bindings of IIS and change the alternate access mapping.   This actually works but isn’t recommended because eventually the bindings in IIS will be overwritten by the original host header URL.  

For Example:

Going to Central Administrator, Services on Server, and stopping and starting the Microsoft SharePoint Foundation Web Application service for the specified server will overwrite any manually updated host header entry in IIS/Site bindings with the original host header URL. 

or

Adding a new SharePoint Server to an existing farm will get the site with the original host header URL after Microsoft SharePoint Foundation Web Application service is started which happens automatically via PSConfig.

 

Explanation

When you create a web application and specify a host header URL, you stamp the host header URL on the spwebapplication object which is stored in the objects table in the configuration database.   When you try to change the host header URL by updating the Alternate Access Mapping and manually update the bindings in IIS, the SPWebApplication object is never updated so it continues to maintain knowledge of the original host header URL and not the new one.   When you start the Microsoft SharePoint Foundation Web Application service in Central Admin, the information from the associated SPWebApplication object in the configuration database is used when instantiating IIS Sites.  This is why the original host header URL shows up.

 

 

Options

The best automated way to update the Host Header URL on a web application is similar to the approach in SharePoint 2007 which is to un-extend and re-extend the Web Application.   That is, disassociate any connection with the existing IIS site and re-establishing that association.   Steps are the following assuming I’m changing my host header URL from russmaxoriginalhost to russmaxnewhost.     

1.  Go to Central Administrator, Application Management, Select the Web Application you wish to change and hit the arrow under Delete and choose  Remove SharePoint from IIS Site.

 

clip_image002

           

2. Next, select the associated site you which to update the host header URL against.    For Delete IIS web sites, select No and hit OK.

image

    

Note:  If you have more than two IIS sites available, that means your web application is extended so choose the appropriate Zone/IIS Site that you would like to update.

           

3. Go to Central Administrator, Application Management, Select the same Web Application and choose Extend button on the ribbon.

 

4. Choose Use an exisitng IIS Site and choose the original site from Step 2 above.   Specify the New Host Header URL and any other settings that should match.  In my case, I updated the Host Header to RussMaxNewHost and hit OK here.

image

 

After updating DNS, the site comes up with no problems.

image

 

 

Question:   What if the web application is already extended to another zone let’s say extranet zone and you want to change host header URL for the default zone?

Answer:  This will still work fine since your only making changes to the IIS site associated with the default zone, the site hosting the extranet zone will remain untouched and should continue to work fine after the above changes.

 

Question:   How can I validate the associated SPWebApplication object in the configuration database contains the new host header URL?

Answer:   You can run the following Power Shell to validate.   Here is a sample:

$wa = get-spwebapplication “http://randomURL”
$iissettings = $wa.GetIisSettingsWithFallback("Default")
$iissettings.serverbindings

This will output the host header URL for the default zone for the web application of your desired URL.

 

Thanks,

Russ Maxwell, MSFT