rorybing Posted February 6, 2012 Share Posted February 6, 2012 Hi, I have a file structure for all my files on my website that works fine for the most part. The basic layout would be something similar to the following. - root folder - sub_folder1 - folder1 - folder2 -sub_folder2 - folder1 - folder2 Each of the folders would contain relative .php files carrying out specific functions etc. The issue I am having is as follows. If I am on a webpage that is located in either of the folder1/folder2 folders, and I need to redirect somebody to a file located in the root folder, I am not able to do this without the page not being displayed correctly. On the file located in the folder1 folder, I have a <? php include("page1.php");?> which works fine. Trying to access a file to redirect to from this folder, I have tried, <? php include("../page1.php");?>, but this only bring me up one level, <? php include("../../page1.php");?> which I think is wrong anyway, and doesn't work, and also <? php include("./page1.php");?>, again does not work. Does anyone know if it is possible to get the file from the subfolders to access a file located directly in the root? Sorry if I'm not being clear explaining the layout etc. Thanks. Link to comment https://forums.phpfreaks.com/topic/256528-file-directory-navigation-php-include/ Share on other sites More sharing options...
trq Posted February 6, 2012 Share Posted February 6, 2012 Use absolute paths from $_SERVER['DOCUMENT_ROOT']. Link to comment https://forums.phpfreaks.com/topic/256528-file-directory-navigation-php-include/#findComment-1315073 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.