Jump to content

Will I run into problem if I do this? (Handling file paths)


bugzy

Recommended Posts

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 :)

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.