benoit1980 Posted April 10, 2014 Share Posted April 10, 2014 Hi everyone, I have been for hours on this and decided to help some help from you at PHPFreak because I just cannot work it out. I am new to PHP and created by first project last night downloading bootstrap 3. To explain the matter faster, all I need to know if how certain scripts can be uploaded both on a remote server and local server without broken css paths and others.At the moment the $_SERVER['DOCUMENT_ROOT'] in my css files and include files are returning:C:/wamp/www/But should returnC:/wamp/www/project_nameAny idea why and how to change this problem please? Now I could for sure hardcore the C:/wamp/www/project_name path but it will kind of kill the idea of seeing in working on local and remote server easily. Could you please let me know if you have a trick for this please? My folders order is(inside C:/wamp/www/project_name): bootstrap functions include public index.php admin Thank you,Ben Link to comment https://forums.phpfreaks.com/topic/287664-path-help-with-php-include-and-css-fileds/ Share on other sites More sharing options...
TheGreek Posted April 11, 2014 Share Posted April 11, 2014 use a relative path. pay attention to where the calling file is in relation to what is calling. for instance your css is in C://wamp/www/project name/css.css and your and your background image is at C://wamp/www/project name/images try #IDName {background-image:url(/images/imagename.jpg;} remember : Starting with "/" returns to the root directory and starts there Starting with "../" moves one directory backwards and starts there Starting with "../../" moves two directories backwards and starts there (and so on...) To move forward, just start with the first subdirectory and keep moving forward as seen in this article http://css-tricks.com/quick-reminder-about-file-paths/ the same should hold tru for included pathes Link to comment https://forums.phpfreaks.com/topic/287664-path-help-with-php-include-and-css-fileds/#findComment-1475764 Share on other sites More sharing options...
Ch0cu3r Posted April 11, 2014 Share Posted April 11, 2014 At the moment the $_SERVER['DOCUMENT_ROOT'] in my css files and include files are returning:C:/wamp/www/ But should return C:/wamp/www/project_name No DOCUMENT_ROOT refers to the root folder that the webserver serves files from (in your case localhost). By default WAMP will (or rather Apache is configured to) serve files from C:/wamp/www If you want to change this you'll need to alter Apaches configuration. Or setup a virtual host for your project so document root refers to your projects root folder. Link to comment https://forums.phpfreaks.com/topic/287664-path-help-with-php-include-and-css-fileds/#findComment-1475780 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.