Added logic: redirect user back to index if visiting a non-existent public profile page