How To Fix SharePoint 404 Error After Content Database Migration

Issue Description

 
If we Google the above text, we will get multiple references for fixing this issue. For this, the traditional ways of fixing are:
  1. The site might have been deleted, request to the site administrator to check the recycle bin.
  2. Do the IIS reset.
  3. Try to access the other layout page like /_layouts/15/settings.aspx(might be default.aspx or home.aspx has some issue).
  4. Clear the timer job cache….etc
None of the above solutions worked for me.
 

Background of the issue

 
Let me give some background about the issue. I have migrated the Content DB using mounting from SharePoint 2013 to 2016. All site collections along with their subsites got opened in the browser without any issue but some of the subsites did not get opened in the browser and threw the "404: file not found" error.
 
If we go to site content structure page, those subsites are available. It looks strange to me! Not getting any clue, I kept on investigating this issue .. I tried to list out the site using SPSite collection PowerShell command. It got listed out, it made me more confused.
 
Then, I tried to connect one of the faulty subsites using ShareGate There,  I saw object reference not set error. Then, I changed the direction of my investigation… I deleted the faulty subsite and tried to recreate it again with the same name manually. Unfortunately, I got the error, "You cannot create a site with this name <IT> as this is a reserved keyword by SharePoint".
 
Well, it confused me more on how this could be a reserved keyword? Then, I went to check the managed path for this web application. Yes, I found the solution…The managed path was the issue. There was a managed path with the name IT in that web application, so we cannot create any subsite with that name with the same hierarchy of managed path. If we delete that IT manages path, we can create a subsite and can access IT along with all subsites under this. This is how I have solved this issue…but nowhere did I get any links or clues about this.
 
This is totally based on my personal experience. For you, the scenario may be different.
 

Example

 
Manged path in the web application: IT
 
I was trying to access the subsite like below.
 
http://server:1010/IT #here IT is the subsite.
 
So, if we have to manage path with the name IT, we cannot browse this subsite along with the all subsites under IT.
 

Solution

 
Check the managed path and remove the managed path which is causing the issue. Here, I have removed IT managed path, then it worked fine.