This is my working setup
Main-Page --> Forum-Page
You can only access the Forum-Page when you are coming from Main-Page. If you access Forum-Page from anywhere else you get back to Main-Page.
Here's the code on my Forum-Page and it works as intended
if($_SERVER['HTTP_REFERER']!=='https://homepage.com/folder/mainpage.php')
{
header('Location: https://homepage.com/folder/mainpage.php');
exit;
}
BUT
if I come back from a Forum-Subpage I also get back to Main-Page. A Forum-Page looks like this
https://homepage.com/folder/forumpage.php?page=view&entry=16
This is what I want to achieve
Main-Page --> Forum-Page <-- Forum-Subpages
So now I need another rule on my Forum-Page that also accept a return from a Forum-Subpage. Since I can't define every subpage I want to add a wildcard at the end like this
https://homepage.com/folder/forumpage.php?page=*
I just don't know how to add this with a correct syntax to my first rule above to make this work. Any ideas are highly appreciated.
I guess you could do something like this
if($_SERVER['HTTP_REFERER']!=='https://homepage.com/folder/mainpage.php'
&& substr($_SERVER['HTTP_REFERER'], 0, 47) !== 'https://homepage.com/folder/forumpage.php?page=')
{
header('Location: https://homepage.com/folder/mainpage.php');
exit;
}
This setup worries me though. I wouldn't to rely on $_SERVER['HTTP_Referer']
; browsers are not guaranteed to set it properly or at all. It especially concerns me that the question is tagged with security as this provides no real security.