SharePoint 2010 - configuring URLs for Internet use (AAR, URL rewriting, alternate access mappings)

Introduction

The Alternate Access Mappings (AAM) of SharePoint allows a website to function correctly under different "inbound" domain names.  This feature can also include reverse proxies and load balancing scenarios. 

 

Assuming that you have two domain names: "fourthcoffee.com" and "contoso.com" - how can you arrange for SharePoint to not just accept and respond to both domain names - but change any (incorrectly) specified domain names that people have accidentally used internally?

An example would be the following:

<a href="https://www.fourthcoffee.com/landingpage.aspx>link to the landing page</a>

while this link works well on the fourthcoffee.com website - the same link will fail if the page is used on Contoso.com.  In general this problem doesn't arise, as virtually all links to content within SharePoint should be "relative links" that don't include a domain name.  An example is:

Relative link:

<a href="https://blogs.technet.com/landingpage.aspx>link to the landing page</a>

How can this problem be solved? As the link is within the HTML itself - then the HTML must be adjusted to translate https://www.fourthcoffee.com into https://www.contoso.com .  This is where ourbound "rewriting" of the web page is useful, and it is often used in conjunction with AAR.

For details on AAR - please see  https://technet.microsoft.com/en-us/sharepoint/Video/ff679917, however I'll include a brief undown on the overall process here:

Assuming that your external domain name is www.sharepointinternet.com :

Create a binding for the Site in IIS to www.sharepointinternet.com

Edit the site bindings

  • Start IIS manager
  • Right-click the site and "edit bindings"
Add a new site binding for "sharepointinternet.com"

 

Create the alternate access mapping in SharePoint 2010

Simply creating the binding in IIS Manager doesn't create the proper binding to Sharepoint - in addition you also need to create the Alternate Access Mapping for the binding itself.

From Central Admin:

  • Choose "application management"
  • Choose "Configurate alternate access mappings"

Edit the alternate access mapping

  • Choose the correct "alternate access mapping collection" at the top right
  • Choose "Edit Public URLs"
  • Add the new URL for the correct zone (eg Internet)

 

Add the reverse rewriting rules (in the HTML)

If the URLs within the HTML refer to the incorrect domain name - these will need to be re-written using the IIS URL Rewriting Module 2.0.  In order to rewrite the HTML returned from IIS - configure the rewrite rule as follows:

Note that you may need to download and install the following:

Additional details on the framework (and ASP.NET routing) are here:

 

For the site

  • Click on URL Rewrite
Add a blank rule

Add a 'precondition' to only process HTML.  A side effect if this is not done is that the URL Rewriter module will error - and send back "500 Server error" messages for non-HTML items such as Javascript.  Sharepoint editing and menus will not work.

 

From "Precondition" - choose "ResponseIsHtml1" - or create a new rule where the Content-type is "text/html". 

 

The rule becomes:

{RESPONSE_CONTENT_TYPE}   <-- Condition input

matches

^text/html

The values should be similar to the following:

Details on the test pattern and captures are available here:

 

Actions

  • The action should be "rewrite"
  • The rewrite value (the new URL) should include a replacement pattern - the "R:1" sections.  These R:(number) sections can be found using the "test pattern" button.

  

Note well - This rewrites the URLs within outbound HTML only.  The inbound URLs (domain names and URLs hitting the SharePoint server aren't affected - these should be catered for using hthe the bindings and alternate access mappings above).

 Choose where URLs and domain names should be matched (generally within A and IMG tags at least)