Reputation: 119
I have my user-based site set up as follows:
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.")
Upvotes: 0
Views: 118
Reputation: 14243
check the random string with database userid
(i suppose the id is the user id) if user id not in db
header("location:404.php");
or
let apache handle for u
in your htaccess file
ErrorDocument 404 /missing.html
or in your php script
header("HTTP/1.0 404 Not Found");
Upvotes: 0
Reputation: 6051
<?php
if(/*USER_DOESN'T_EXIST*/)
header("HTTP/1.0 404 Not Found");
?>
Upvotes: 2