Jump to content

Path help with php include and css fileds


benoit1980

Recommended Posts

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 return
C:/wamp/www/project_name

Any 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
 

 

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

 

 

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.

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.