Jump to content

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


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.