Moving a Sub-Site
At work the other day, I was asked to move 3 sub-sites from one site to another.
I’ve never done this before, so a colleague gave me guidance with the following steps:
‘Site Actions’–>’Manage Content and Structure’–>(Click on the site where sub-site exist)–>(on the right side, check sub-site(s) you want to move)–>’Actions’—>’Move’
The moving of the sub-sites worked like a charm but there was one tiny problem. When the users would navigate to the old sub-site, it did not redirect them to the new one. In fact, the old site did not exist anymore because it was moved.
So, how do I solve this issue?? Now the following is not a perfect solution, I don’t even know if it’s good practice but here’s what I did (And I only did it this way because there were only 3 sub-sites to move. If there were a lot more, I would have looked for another solution). I followed my colleague’s steps above and when I got to ‘Actions’, I selected ‘Copy’ instead of ‘Move’.
Then, on the pages that I needed to redirect from, I added a CEWP and linked to a JavaScript file with the following code.
<script type=”text/JavaScript”>
var pathName = window.location.pathname; //pathName value: https://myServerDomain/mySite/oldsubsite/Default.aspx
var newPathName = pathName.replace(“oldsubsite”, “newsubsite”);
alert(“Please take note of the new location. You are now under knowledge Management structure.”);
window.location.replace(newPathName); //newPathName value: https://myServerDomain/mySite/newsubsite/Default.aspx
</script>
That was quick and dirty but it worked for what I needed.