Glese Posted November 28, 2011 Share Posted November 28, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/251917-proper-use-of-path-structure-for-folder-structure-with-multiple-levels/ Share on other sites More sharing options...
TwoSaints Posted November 28, 2011 Share Posted November 28, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/251917-proper-use-of-path-structure-for-folder-structure-with-multiple-levels/#findComment-1291684 Share on other sites More sharing options...
Glese Posted November 28, 2011 Author Share Posted November 28, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/251917-proper-use-of-path-structure-for-folder-structure-with-multiple-levels/#findComment-1291694 Share on other sites More sharing options...
Glese Posted November 28, 2011 Author Share Posted November 28, 2011 I got it to work, I had a mistake in the path. Quote Link to comment https://forums.phpfreaks.com/topic/251917-proper-use-of-path-structure-for-folder-structure-with-multiple-levels/#findComment-1291696 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.