Skip Ribbon Commands
Skip to main content

Quick Launch

Todd Klindt's home page > Todd Klindt's Office 365 Admin Blog > Posts > Redirection options in SharePoint
August 19
Redirection options in SharePoint

I see questions about redirecting users in SharePoint all the time. Usually they're in the context of "I want to redirect users, can I do this with an Alternate Access Mapping?" SharePoint admins know that if they don't set their AAMs up correctly that SharePoint will bounce their users around like a SuperBall, so they hope they can harness that power for good, instead of evil. While you can in certain circumstances most likely you will want to use a different approach. In this blog post I will show you several different to redirect users in SharePoint. Then when you find yourself needing to, you can use the method best suited for your situation.

When deciding which redirection method to employ, you need to determine what you're redirecting from and what you're redirecting to. That will determine which method to use. For each of the methods I discuss below I will provide examples of the situation you would use it in. Enough with the introduction, let's get down to it.

Vanity URLs

One of the most common requests I see is for vanity URLs. SharePoint URLs can get long and unmanageable and admins want URLs that their users can remember. They want to use something like http://software and have it forwarded to http://team/sites/software/development. To set expectations correctly, you should just come to terms with the fact that you aren't going to write SharePoint URLs down, you'll pass them along via or IM. If you do want short URLs you can have them forward to deep SharePoint sites. Of course the URL your users will eventually get to will be the long URL, but the jumping off point will be easy to remember. To do this kind of redirection I use IIS directly, I don't get SharePoint involved at all. Create a new virtual server in IIS Manager and give it a descriptive name like "Software Redirect." When you're walking through the wizard you'll take the defaults. You'll have to point it to a local directory. This is only temporary, so you can point it anywhere. After the virtual server is created, edit the properties. Open the "Home Directory" tab and click "A redirection to a URL" then type your SharePoint URL in the "Redirect to:" box. It should look like this:

 

Figure 1 – Redirection settings

This method works pretty well and is easy for users. It does have a couple of drawbacks you should know about. Each virtual server running takes up RAM on your IIS server. You can take steps to mitigate this. I create a new App Pool and use it strictly for the redirect virtual servers. Then I set that App Pool to timeout if idle for 1 minute. Since this App Pool does not really do much, it does not use much RAM, but this reduces that memory footprint liability to only a minute or two on your web server each time someone uses the redirect. In my experience the App Pool only used 5 or 10 MB of RAM each time someone hit it. With today's machines that's not much of a hit. Overall I've been very happy with this approach.

 

Figure 2 - App Pool memory settings

Server URL has changed and users have bookmarks

This can happen from time to time, a server name changes or you move your site from HTTP to HTTPS. If your users have bookmarks to the old URLs this can cause problems. One option is to tell your users they're out of luck, but this is a great opportunity to look like a SharePoint Hero. You may be able to use AAMs to work this type of redirection, but they don't work consistently. For instance, the AAM will redirect a URL without a page, but will not redirect one that does. So http://oldserver would redirect but http://oldserver/default.aspx would not. Because most bookmarks will have the page included we can't rely on this. To handle this I employ a technique similar to how I handle Vanity URLs. First you'll need to make sure your existing SharePoint virtual server no longer responds to the old URL. Normally I just change the port to an used port like 8080, so that it's easy to change back. Next create a new virtual server and make sure it responds to the old URL, so you may need to add a host header or adjust the port. Like above, after you've created the redirect virtual server edit its Home Directory property. Instead of feeding it a static URL we're going to employ some redirect variables. Before I explain them, here's what your redirect URL will look like:

 

Figure 3 - Redirection variables

Two changes should jump out at you. First, the URL ends in $V$Q. The $V represents the original URL the user is trying to access, but without the protocol, servername or parameters. The $Q represents any parameters the URL included. Here's a crude drawing of how the URL breaks down:

 

Figure 4 - URL breakdown

Since all we want from the old URL is the path and the parameters, $V$Q works well for us. You can find a list of all the supported redirection parameters here. You'll also want to check the "A permanent redirection for this resource." This gives the client back an http 301 reponse which tells it the redirect is permanent. Some clients can understand this and will fix the Bookmark to the new URL. Other clients can't understand 300 level responses at all and will fail completely regardless. Full documentation on this switch and the rest can be found in the IIS Manager help. Once the screen is up you can hit F1 to open the help. After you have this all configured any requests this virtual server handles will be forwarded with path and parameters to the URL you specified.

Redirect from Deep URL

Sometimes you aren't redirecting an entire URL, or even just the servername. Sometimes you're just moving a web and you want users to be redirected to the new location. Since you don't want to redirect the entire web application you can't use either of the previous techniques. Fortunately there is a way. There is much magic in the Content Editor Web Part (CEWP) and this is another example. You can use a CEWP to insert HTML code to send your users wherever you want them. To utilize it add a CEWP to your web part page, usually the default.aspx at the root of your web. Edit the web part properties. Click Source Editor and add a Meta Refresh tag to send your users to the new site. It will look like this:

<meta http-equiv="refresh" content="10;url=http://ames">

 

Figure 5 - CEWP Properties

The "10" in the content tag means the page wait 10 seconds before it refreshes. A longer time is handy if you want to put a message alerting your users to the new location before you forward them. The URL is the URL your users will be sent to. Of course this will only work on the page you put it on, so you may need place it on multiple pages in your web, like your Shared Document library pages. Fortunately since it is just a web part you can export it and import on additional pages, you don't need to recreate it each time.

There are some drawbacks to this approach, and it's generally considered bad form to use a refresh tag to forward users. For one it breaks your users' Back button in their browsers. It can also confuse your users, especially if the redirect is fast and there isn't a note on the page explaining that the site has moved. Finally, make very sure the URL you're redirecting them to is valid. If not they get stuck on a dead page and no way to use Back to get out. Sometimes it is your only option though.

This blog post wouldn't be complete without a mention of MOSS' Redirect Page content type. If you're using MOSS and you're on a Publishing Site you can access to it. Go to your Pages document library and Click new. It will be in your list.

 

Figure 6 - Redirect Page content type

Once the Redirect Page is created you'll need to Edit its Properties and enter the URL you want it to redirect to. You'll also need to preview the page and check it in before it will work. Unfortunately this solution only works on Publishing sites.

As you can see, SharePoint and IIS provide many ways to redirect users. Each method has its benefits and drawbacks. Hopefully this blog post will provide you with one method that will work for your situation.

tk

 

Comments

An extra tip ($S)

Todd,

Firstly, thank-you for highlighting how to do this, I've struggling with exactly this scenario for weeks!

Secondly, I have something to add. My scenario: I moved a site (previously http://server/it) to a new location underneath a parent site (http://server/group/it).  My users now hate me becuase all their silly hardwired URLs to documents are all broken.

Your Redirection Variables tip didn't quite work for me  You've suggested my redirecting virtual server should point to: http://server/group/it$V$Q, but this didn't work for me.  Howver reading through the documentation you linked, I found that http://server/group/it$S works perfectly.

I'm a hero again!

R.
 on 8/20/2007 5:55 AM

Thanks very much Todd.

I used Redirect from Deep URL method worked great for me.
 on 9/20/2007 5:40 PM

Thanks nice Article but a have a couple of questions.....

RE the vanity URL i have attempted this but to no avail

I am have a sharepoint server with 5 subsites in the format of
\\serverx\sites\site1
\\serverx\sites\site2
\\serverx\sites\site3
\\serverx\sites\site4
\\serverx\sites\site5

these are being migrated to a new server in the format of
\\servery\sites\site1
\\servery\sites\site2
\\servery\sites\site3
\\servery\sites\site4
\\servery\sites\site5

the sharepoint sites are all subsites of one main site - is it possible to use the vanity URL  method with this sort of setup? as i dont see any obvious way of specifying where you choose the originating site in IIS or am I missing something - as this wasnt illustrated int he IIS redirection settings?

I assume this will not work as they are all subsites of the default sharepoint 80 site in IIS.

Or is the only option using the hardcoded CEWP method which I have tested sucessfully......

Hope you can help me out - many thanks for the info.


 on 10/11/2007 10:08 AM

What about the _layouts directory?

By the way, your suggestion worked great for redirection of a bookmarked document library.   Thank you!  I still cannot get the _layouts directory to redirect if it has been bookmarked. 

Kelly
 on 10/31/2007 3:06 PM

vAx

How would you go about redirecting 4 different domains to the right site.

I have 4 sites under the main web application:

http://sharepoint (site 1)

http://sharepoint/site2

http://sharepoint/site3

http://sharepoint/site4

These 4 domains need to be redirected to the right site as follow:

www.site1.com goes to http://sharepoint
www.site2.com goes to http://sharepoint/site2
www.site3.com goes to http://sharepoint/site3
www.site4.com goes to http://sharepoint/site4

 
I do have 4 different Master pages and the sites look totally different from each other.

I want to preserve my DNS settings so if my users will type www.site1.com it should keep the domain name not the internal URL http://sharepoint/site1

I tried to use AAM but it doesn't work. I cannot specify more than one Intranet zone.

Thanks!
 on 12/9/2007 6:58 PM

Re: vAx

I don't think there's a way to do that out of the box.  I think you could do it with ISA Server 2006 possibly.

tk
Todd O. KlindtNo presence information on 12/9/2007 10:08 PM

Is there a way to support dynamic redirects using MOSS 2007 redirect page layout?

is it possible to redirect users to different pages based on condition?
 on 1/28/2008 4:41 PM

Re: Is there a way to support dynamic redirects using MOSS 2007 redirect page layout?

What conditions do you want to look at?  Have you looked at Variations?  They may do what you're looking for.

tk
Todd O. KlindtNo presence information on 1/28/2008 4:51 PM

Re: Is there a way to support dynamic redirects using MOSS 2007 redirect page layout?

Thanks Todd.

Conditions could be based on User profile properties. If user has a specific property value I would like to redirect him to a specific site from where he can start browsing.

Or

Is it possible to pass a redirect url as query string parameter dynamically to the page created using redirecting template?

Also if we do not want to view the page(content shown during redirect : You will be redirected in 5 seconds..) during redirects, what would be the options?
 on 1/28/2008 9:57 PM

Site Redirection (similar to vAx above)

We are setting up 94 collections in SharePoint 2007 with the following naming:
http://districtweb.aaa.gov/districts/districtcode, each collection having a unique districtcode.

We want to have 94 redirects of
http://districtcode.aaa.gov to http://district.aaa.gov/districts/districtcode.

Is there a way to programatically do this without creating 94 separate web site redirects?
 on 2/12/2008 9:35 AM
1 - 10Next

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Title


Body *


Today's date *

Select a date from the calendar.
Please enter today's date so I know you are a real person

Twitter


Want a message when I reply to your comment? Put your Twitter handle here.

Attachments

 

 SysKit