We are migrating from SP 2013 to SP 2016. There are multiple sub-sites under the main site and further sub-sites under those sub-sites. The users may have bookmarked specific libraries and lists from the old URL and they need to be routed to the main page of the sites with the new URL. For example,
OLD URL:
https://abc/subsite1/subsite2/subsite3
NEW URL:
https://xyz/subsite1/subsite2
Now the sub-sites in the SP 2013 are inheriting the master page from the Subsite1 level. If it was a simple redirect where every site had their own master page I could have used JavaScript like:
location.href="[new url]"
and be done with it. Now I believe I need if-else statements in the sub-site 1 master page to check for what URL the user is using and then redirect it.
I have tried the following:
if(location.href=='https://abc/subsite1/subsite2/subsite3/')
{
location.href='https://xyz/subsite1/subsite2';
}
else if(location.href=='https://abc/subsite1/subsite2/subsite3/')
{
location.href='https://xyz/subsite1/subsite2';
}
The issue is user may have bookmarked a list from abc and the check would fail. How do I just check for the path till sub-site2 with JavaScript?
I am open to other ways of achieving this in SharePoint as well.