Redirecting a SharePoint Subsite or a Site collection to a different URL


Lots of times I have been asked this question if there is a way to redirect a subset to a different URL

I have seen many people trying this by playing around AAM and at the IIS level. I will try to put bit of light on both of them and will also show you a easy way out of it

1) AAM(Alternate Access Mapping)

This option will not work out as we cannot add Subsite URL in this. For Example we can add the following types of URL in the AAM

A) http://ServerName

B) http://FQDN

Now this is good if you want to do a redirect of the whole url where if browse to http://ServerNameA we are redirected to http://ServerNameB but this option will not help in redirecting a Subsite to a different URL

2) IIS Level

We can redirect a Virtual Dir with help of this. But SharePoint Subsite wont show up in IIS as they are stored in database. So one way we can think is create a Virtual dir of each URL you want to redirect then create exclusion in SharePoint and redirect it from IIS

Now if you several Subsites then this is a not a good option.

Following are the steps which will help us in redirecting any level of site in SharePoint in a pretty neat manner. We will try to redirect http://mosssps/sites/Team/default.aspx to http://mosssps

1) We will open the site in Web Folder view

clip_image002

2) Download default.aspx page of the site which we want to redirect. There are other ways to access default.aspx page too.

clip_image004

3) Open the default.aspx in notepad and delete all the contents of it

4) Add the following code to it

<%@ Page language="C#" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>

<script>

window.location.href = "http://mosssps/Pages/Default.aspx";

</script>

5) http://mosssps/Pages/Default.aspx is the URL where we want it to redirect if browse to http://mosssps/sites/Team/default.aspx

6) Upload the Default.aspx and now when you browse to http://mosssps/sites/Team/default.aspx it will redirect to http://mosssps/Pages/Default.aspx.

 

Note- I have only tested this on Moss.If you are intending to use this for V2 then you may wanna test this first


Comments (14)

  1. vijay says:

    Time waste

  2. sharepoint developer training says:

    As a Newbie, I am constantly exploring Online for articles that can be of assistance to me.Thank you
    http://staygreenacademy.com/sharepoint-developer-training-online/

  3. Prasath C says:

    Nice Article. Thanks

  4. Anu Dhulipudi says:

    Add a content editor web part on the page you wanted to re-direct and edit HTML to add

  5. Anonymous says:

    Pingback from How to redirect user to other site collection in same web application? – FAQs System

  6. Mohd Faisal says:

    But this will only redirect the home page. What is users try to directly hit a list or library within the site and have favorites pointing to the content instead of the home page ?

  7. SPbb says:

    How about if they have a bookmarked the sub sites ug document library this won’t work.

    Any idea?

    Thanks!

  8. kim says:

    Thanks for the post. I’ve used the code in the default.aspx file to redirect from on an on-premise SP environment to another SP environment, but now I’m wondering if it’ll work to redirect for an on-premise SP environment to the Online site? Or if there is another option for that?

    Thanks
    Kim

  9. tony says:

    THANK YOU SO MUCH!!.  I have in sub-site that I manage in Sharepoint 2010 and I had to rename the site but not lose the old URL as many people had it saved in their favorites.  With no access to the server environment, I was able to use this code to replace the code of my old site to redirect to the new site name, renamed the old site to the new site name and everything is working great!

  10. Adriana says:

    Does anyone know what it means to create exclusion in SharePoint mentioned on option # 2 (IIS level)? I am interested in that option as I only need to redirect one site

  11. Anonymous says:

    Great post…much appreciated

  12. Luigi Bruno says:

    Is there something equivalent for SharePoint 2010? We have changed the web application for a site collection, the old site collection is still available in read-only mode (via the Quota and Locks option in the Central Administration): we're looking for a way to redirect the old home page to the new one.

Skip to main content