Jump to content

Proper Use of Path Structure for Folder Structure with Multiple Levels?


Recommended Posts

When having different levels of directories, using relative paths will not work anymore, for example:

 

 

controller

- authentication

 

File 1: include('../../model/header.php')

 

 

 

model

 

File 2: header.php

 

 

 

view

 

File 3. style.css

 

 

 

The header.php file includes the css file with a relative path, but the problem is it includes it as follows: ../view/style.css

 

 

When now the header.php file gets included into File 1 in the folder "authentication", then the css file will not be accessible anymore, for it to be accessible you would have to go two directories up.

 

In this sense my question is, what would be the proper path structure for a folder structure with multiple levels? Should I rather use absolute paths, I am not so prone of absolute path. What if the folders changes a bit, or the domain changes, or the location changes?

can you use links relative to the site root - this is done by simply prefixing a / to your relative urls:

 

 

/view/styles/style.css

is equivalent to

www.mysite.com/view/styles/style.css

I think what I actually have to do is, I have to make the css file an absolute path.

 

Though how do you do an absolute path on a local server?

 

c:/ et cetera did not work for me and http://localhost/ et cetera did not work for me either. Any suggestions?

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.