Prevent Direct Access to Web Page...

User 452266 Photo


Registered User
267 posts

Need the following solution. (The links below are not the real links, just used for an example)
I have one web page in a directory called www.mywebsite.org/main/index.html
I have another web page in a directory called www.mywebsite.org/register/register.html
How can I have the register.html web page deny opening the page unless they click on a menu item, or link in the index.html page?
My reason is I have people keep giving out the direct URL of www.mywebsite.org/register/register.html because they seem to think that it saves people clicks.
I need them to go to www.mywebsite.org/main/index.html first and click on a registration link because there are a lot of other items/information on this page that I want them to see.

May The Good Lord Take A Likin' To You,
Sandcrab3 (Scooterman)
User 187934 Photo


Senior Advisor
20,190 posts

Give this a try. It needs to be at the very top of your page.
<?php
$referrer = $_SERVER['HTTP_REFERER'];
if (!preg_match("/main/index.html",$referrer)) {
header('Location: http://www.mywebsite.org/main/index.html');
} ;
?>

I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 452266 Photo


Registered User
267 posts

Eric Rohloff wrote:
Give this a try. It needs to be at the very top of your page.
<?php
$referrer = $_SERVER['HTTP_REFERER'];
if (!preg_match("/main/index.html",$referrer)) {
header('Location: http://www.mywebsite.org/main/index.html');
} ;
?>


At the top of my index.html page, or at the top of the register.html page?
Thanks,
Neil

May The Good Lord Take A Likin' To You,
Sandcrab3 (Scooterman)
User 187934 Photo


Senior Advisor
20,190 posts

Reg page.:)
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 452266 Photo


Registered User
267 posts

Eric Rohloff wrote:
Reg page.:)

It doesn't seem to work. The pages that I'm testing it on are:
http://www.therideahead.org/test/direct/index.html
http://www.therideahead.org/test/direct/access.html

May The Good Lord Take A Likin' To You,
Sandcrab3 (Scooterman)
User 187934 Photo


Senior Advisor
20,190 posts

Add this line to your .htaccess file or rename the pages with a .php extension.
AddHandler application/x-httpd-php .php .html .htm
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 452266 Photo


Registered User
267 posts

Eric Rohloff wrote:
Add this line to your .htaccess file or rename the pages with a .php extension.
AddHandler application/x-httpd-php .php .html .htm


Hey Eric. I appreciate the help. I have tried renaming the files (one & both). I have also edited the .htaccess file. And I still get the same results.

My email address is np77375@gmail.com if you want to have ftp access to the directory/files.

Thanks,
Neil

May The Good Lord Take A Likin' To You,
Sandcrab3 (Scooterman)
User 187934 Photo


Senior Advisor
20,190 posts

What was the actual code you placed at the top of your page?
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 452266 Photo


Registered User
267 posts

Eric Rohloff wrote:
What was the actual code you placed at the top of your page?


This is the entire code:

<?php
$referrer = $_SERVER['HTTP_REFERER'];
if (!preg_match("/test/direct/index.php",$referrer)) {
header('Location: http://www.therideahead.org/test/direct/index.php');
} ;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<body style="color: #FF0000; background-color: #00FF00">
<p>THIS IS THE ACCESSED PAGE.</p>
<p>THIS SHOULD NOT BE AVAILABLE WITHOUT GOING TO THE MAIN PAGE FIRST.</p>
</body>
</html>

May The Good Lord Take A Likin' To You,
Sandcrab3 (Scooterman)
User 2147626 Photo


Ambassador
2,958 posts

Go to the site in my sig and scroll to the bottom. You'll see 3 icons on a shelf. Click the left most. You won't be disappointed!

However, if you are, shoot me an email and I'll see if I can help. :P
Graphics for the web, email, blogs and more!
-------------------------------------
https://sadduck.com

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.