URL redirect for pages with parameter only
Working on a small project that requires users to register/log in.
So far, if a visitor (not logged in) types in profile.php, they'll
automatically get redirected to the homepage.
Now, what I'm trying to accomplish is to NOT redirect them if they want to
check out a user's profile in particular, like profile.php?id=22.
Here is what I have so far:
if ((!preg_match(" {(?:login|logout|signin|register|profile)\.php$}",
$_SERVER["PHP_SELF"])) && (empty($_SESSION["id"])) )
{
header('Location: home.php');
}
Unfortunately this will redirect all visitors who type in profile.php?id=22.
I've tried to add profile.php?id=$id but no luck.
In a nutshell,
profile.php should redirect and profile.php?id=$id shouldn't.
No comments:
Post a Comment