I have my user-based site set up as follows:
- Each user has their own profile page at mydomain.com/user123
- Behind the scenes, and unbeknownst to the user, this redirects to mydomain.com/profile.php?user=user123
If someone visits any URL like mydomain.com/randomstring, how would I ensure that the viewer does not see “mydomain.com/profile.php?user=randomstring” in instances where “randomstring” is not equal to a current username that is registered with my site, but instead they see a 404 error?
(for reference purposes, profile.php populates a pre-defined template that pulls custom variables associated with each unique username. Therefore, if a certain username doesn’t exist, going to mydomain.com/randomstring would bring up an empty page titled “randomstring’s profile page.”)
1 Answer