The MVC routing engine points an URL to an action method rather than a html page. So in this actionmethod you can choose which html views will be returned depending on some coding conditions.
I'm not saying this is the approach they use, but this is an approach you could use.
So in ASP.NET MVC you could achieve this by using something like:
public ActionResult ViewProfile(string userToView)
{
var model = new MyModel();
//all the logic to fill the model
if(CurrentUser.IsLoggedIn)
{
return View("ViewProfile", model);
}
else
{
return View("ViewProfileNotLoggedIn", model);
}
}