0

I need to redirect the subsite URL to Root site collection, For example, if I accessed the ~sitecollection/departments means, It needs to redirect to ~sitecollection, Is it possible? or Is it possible to create a virtual as sites/departments? I tried http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=48 this, but I am not clear, Please suggest me some idea to achieve this .

1
  • What is the requirement behind this? Maybe there's another way to solve this because this approach seems a bit unconventional at least.
    – Mx.
    Commented Dec 9, 2016 at 14:42

1 Answer 1

0

Add below code in your master page, this will redirect to root site if user try to access subsite.

$(document).ready(function() {
       var siteUrl = _spPageContextInfo.siteServerRelativeUrl;
       var webUrl = _spPageContextInfo.webServerRelativeUrl;
       var isRootWeb = siteUrl == webUrl;
       if(isRootWeb == false){
        window.location.replace(_spPageContextInfo.siteAbsoluteUrl);
       }
 });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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