bugzy Posted August 22, 2012 Share Posted August 22, 2012 Finding the right path is a pain in the @ss especially for a beginner like me. If you have huge list of directories and files it is very time consuming especially if you put your websites live in an online server and you run into different errors and issue that involves file paths. I wonder if I will run into problem if I use absolute path on all my files? I'm planning to do it this way.. I have this file called "domain" with values $domain = "www.mywebsite.com"; and I will going to include that file on all my files so instead of using $path = "../../../stylesheet.php" I will use $path = $domain . "/directory1/directory2/stylesheet.php"; So regardless on where I am going to deploy it and regardless of what directory I will put the website, I will just change 1 file which is the domain file and its values. Will I encounter any problem if I do this? I wonder how you guys are handling paths, if you have some easy way to handle it.. pls. do share it here.. It will be very helpful for a beginner like me Quote Link to comment https://forums.phpfreaks.com/topic/267418-will-i-run-into-problem-if-i-do-this-handling-file-paths/ Share on other sites More sharing options...
Adam Posted August 22, 2012 Share Posted August 22, 2012 You can avoid all that headache by having an Apache* VirtualHost for each site. Using a virtual host you just configure the DocumentRoot to point to the root directory of the website, access it through a URL such as "http://myvirtualhost.local" and all paths in the HTML can then just be prefixed with a slash: "/directory1/directory2/stylesheet.php". * If you're not using Apache there's equivalents for most web servers. Quote Link to comment https://forums.phpfreaks.com/topic/267418-will-i-run-into-problem-if-i-do-this-handling-file-paths/#findComment-1371400 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.