rupurt Posted February 22, 2007 Share Posted February 22, 2007 i am running apache with php5 installed as an apache module. when i try to access files (to open or include etc...) it tries to get the file from the root of the file system rather than the root of the virtual host. here is an example. I am running virtual host test.heg2.com. I want to check if the index.php file exists if(file_exists("/index.php")) print "file exists"; else print "file does not exist"; this never finds the file. However if i put index.php in the root of the file system it finds the file. I have tried setting the doc_root in the apache httpd.conf file and it does set the doc_root to the path of the virtual host but this makes no difference. Is it possible to reference / as the root of the web directory rather than the root of the filesystem? What can i do to solve this problem? Link to comment https://forums.phpfreaks.com/topic/39593-opening-files-using-absolute-path-from-document-root-uses-root-of-filesystem/ Share on other sites More sharing options...
interpim Posted February 22, 2007 Share Posted February 22, 2007 could you build the php to look for the file via the path from root? such as /phpfilefolder/index.php Link to comment https://forums.phpfreaks.com/topic/39593-opening-files-using-absolute-path-from-document-root-uses-root-of-filesystem/#findComment-191054 Share on other sites More sharing options...
heckenschutze Posted February 22, 2007 Share Posted February 22, 2007 Your in fact telling it to look in root, if you want to check in the current directory use: if(file_exists('./index.php')) ... OR if(file_exists('index.php)) ... The post-'/' means root directory - so infact it SHOULD be showing the root of the filesystem. Most filesystem (NTFS, EXT) conventions state this behavoir shouldn't be changed. Link to comment https://forums.phpfreaks.com/topic/39593-opening-files-using-absolute-path-from-document-root-uses-root-of-filesystem/#findComment-191057 Share on other sites More sharing options...
rupurt Posted February 22, 2007 Author Share Posted February 22, 2007 is there anyway to change the meaning of /? On shared hosting ive used referencing documents via / before. I know you can run apache in a chroot jail but that wouldn't work for each virtual host. Link to comment https://forums.phpfreaks.com/topic/39593-opening-files-using-absolute-path-from-document-root-uses-root-of-filesystem/#findComment-191071 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.