Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a web application named : "WebApplication:8000" in that I have created four site collections in that web application.

  1. WebApplication:8000 (Root)
  2. WebApplication:8000/sites/team1
  3. WebApplication:8000/sites/team2
  4. WebApplication:8000/sites/team3

Now I want to redirect the user of "WebApplication:8000/sites/team1" to "WebApplication:8000".

I found this post which explains to redirect the user from home page but the problem is that when I enter the url "WebApplication:8000/sites/team1/SitePages" I am not being redirect to the root url.

I want to completely stop the user landing to the any page of "WebApplication:8000/sites/team1"

What should I do?

share|improve this question
    
Can't you add a script to the master page to redirect to the root site collection? –  wjervis Apr 2 at 12:31

2 Answers 2

After searching over internet four hours I found one thing. That it is not possible to make alias of the url because the site collections lie within same web application. So, that way was not possible for me.

The final solution is to create an HttpModule for web application that checks specific url, if it meets the condition then redirect that request to desired site collection.

Create one class library in the visual studio. And place the below code.

Below is the code which shows the logic for creating http module.

namespace DynamicModule
{
    public class DynamicModule : IHttpModule
    {
        public void Init(HttpApplication context)
        {            
            context.BeginRequest += new EventHandler(context_BeginRequest);
        }

        void context_BeginRequest(object sender, EventArgs e)
        {
            HttpApplication application = (HttpApplication)sender;
            HttpContext context = application.Context;
            string httpUrl = context.Request.Url.ToString();
            if (httpUrl.Contains("/sites/team1"))
            {
                HttpContext.Current.Server.ClearError();
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.Redirect("http://www.google.co.in");
            }
        }        
        public void Dispose() { }
    }
}

After writing the code build the solution and go to the dll file that is created after build.

Now go to the bin folder of web application.
In my case below is the path:
C:\inetpub\wwwroot\wss\VirtualDirectories\8000\bin
Paste dll here.

Now open the web.config file of the web application and find tag.

Create one entry here like:

<add name="NameOfModule" type="Namespace.Class,Full dll name with culture and public key token/>

Enjoy....!!!

Hope this helps others too.

share|improve this answer

It is doable scenario for IIS URL Rewrite Module . Please refer Using the URL Rewrite Module for a details.

Since REDIRECT is supported operation in SharePoint 2007/2010/2013 according to Microsoft, the following scenario could be configured:

  • Client makes a request to http://webapplication:8000/sites/team1
  • IIS with Rewrite Module receives the request to http://webapplication:8000/sites/team1
  • URL Rewrite module creates a redirect to http://webapplication:8000 and then sends the HTTP redirect (301,302 etc.) back to client
  • Client receives redirect and then makes a new request with the new URL http://webapplication:8000
  • SharePoint receives the request and processes normally.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.