Click to See Complete Forum and Search --> : Looking for a Script


blahpunk
03-30-2006, 08:56 PM
I'm looking for a script that will stop users from directly access subpages but only through the main page. If they goto a subpage it'll redirect them back to the homepage. Is this possible? Or is there a script currently out?

balloonbuffoon
03-30-2006, 09:11 PM
This must come before anything it sent to the browser.

$main_page = "http://website.com/main.php";
if ($_SERVER["HTTP_REFERER"]!=$main_page) {
header("Location: ".$main_page);
}

blahpunk
03-30-2006, 09:19 PM
Thats all? Wow. Thanks.

blahpunk
03-30-2006, 09:28 PM
Opps im sorry, I meant for a php script to work with html and shtml pages.

balloonbuffoon
03-30-2006, 09:31 PM
That will, just do this:

<?
$main_page = "http://website.com/main.html";
if ($_SERVER["HTTP_REFERER"]!=$main_page) {
header("Location: ".$main_page);
}
?>
<html>
<head>
<title>Subpage</title>
</head>
<body>
Content...
</body>
</html>

blahpunk
03-30-2006, 09:48 PM
sorry, it isn't working. I can access the page directy without coming from my main page.

chazzy
03-30-2006, 09:50 PM
did you put that piece of code on all of your pages? you mentioned .html and .shtml pages, did you configure htaccess to parse those pages using php?

blahpunk
03-30-2006, 10:02 PM
All pages have the script. I haven't got a clue how to setup the parsing. I do use my htaccess.

chazzy
03-31-2006, 06:38 AM
when you view the page, does it show the code you put on it? you should rename the page to .php preferably.

bokeh
03-31-2006, 06:52 AM
First you need to be certain PHP is enabled on your server!you should rename the page to .php preferably.That's right but it is also possible to send other extensions to the php parser by adding the following to .htaccess in the root directory.AddHandler application/x-httpd-php .html .htm