stupidav Posted May 20, 2007 Share Posted May 20, 2007 I am putting together a page made up of several pages using PHP, I am pretty new to PHP. My main page is listed below. What I am afraid of is, search engines will only list one of the items that I am "including". I have seen where cookies are used for passwords protected pages, to redirect to a login or other page. Is somthing along those lines, going to be the best way to ensure that if someone tries the www.xxxxxxx.com/body.php that it redirects to www.xxxxxxx.com/index.php, which will assemble the page properly with the ....body.php? The pages are not password protected. If so how do I make the cookie expire, once the page completes loading? I thought that it might be better to at the top of the page set a variable to a specific value, and then at the begining of each of the individual pages, look to see if the variable = specific value, if so continue, of not redirect, and at the end of the last page clear the variable? If this is possible, what would it be called so I can look it up, and learn or are there any examples I can look at? index.php <?php define('IN_PHP', true); $php_root_path = './'; include($php_root_path . 'extension.inc'); include($php_root_path . 'root.php'); /*?>for the meta and header part of the page<?php */ include($php_root_path . 'header.php'); /*?>for the header part of the page<?php */ include($php_root_path . 'nav.php'); /*?>for the navigation bar part of the page<?php */ include($php_root_path . 'body.php'); /*?>for the main body and content part of the page<?php */ include($php_root_path . 'footer.php'); /*?>for the footer part of the page<?php */ ?> Link to comment https://forums.phpfreaks.com/topic/52258-solved-how-to-prevent-the-include-content-from-being-called-independantly/ Share on other sites More sharing options...
chigley Posted May 20, 2007 Share Posted May 20, 2007 In a forbidden file: <?php if (!defined("IN_PHP")) { header("Location: index.php"); } // Rest of code here ?> Link to comment https://forums.phpfreaks.com/topic/52258-solved-how-to-prevent-the-include-content-from-being-called-independantly/#findComment-257836 Share on other sites More sharing options...
stupidav Posted May 20, 2007 Author Share Posted May 20, 2007 So if I understand this correctly, this would go in the individual pages. if (!defined("IN_PHP")) this is asking if not "IN_PHP" then {header("Location: index.php"); } redirect to "index.php" else if "IN_PHP" then do everything else, correct? Link to comment https://forums.phpfreaks.com/topic/52258-solved-how-to-prevent-the-include-content-from-being-called-independantly/#findComment-257853 Share on other sites More sharing options...
MadTechie Posted May 20, 2007 Share Posted May 20, 2007 no Add <?php if (!defined("IN_PHP")) { header("Location: index.php"); } // Rest of code here ?> to the top of all pages you DO NOT what a user to go directly to.. Link to comment https://forums.phpfreaks.com/topic/52258-solved-how-to-prevent-the-include-content-from-being-called-independantly/#findComment-257861 Share on other sites More sharing options...
stupidav Posted May 20, 2007 Author Share Posted May 20, 2007 Thanks very much! Link to comment https://forums.phpfreaks.com/topic/52258-solved-how-to-prevent-the-include-content-from-being-called-independantly/#findComment-257867 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.