Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

vegaspass00

macrumors newbie
Original poster
Feb 16, 2009
1
0
Hi,
I have Apache running and i'm tring to get my website running on my localhost before I push it to my live server but i'm unable to see some of the javascript and css files with relative url paths.

for example:
if i go to my index page
http://localhost/~username/mywebsite/index.php
when i try and use the relative path for the css file: /includes/css/main.css

it thinks my css file is at this path
http://localhost/includes/css/main.css
but it is actually supposed to be at this path
http://localhost/~username/mywebsite/includes/css/main.css

does anyone know what settings i need to change in order for the relative paths to work on my localhost.

thanks
 
Removing the / before includes should do it. Initial slash characters refer to the root path--you want the includes path that is a subdirectory of the current directory, not the root.
 
for example:
if i go to my index page
http://localhost/~username/mywebsite/index.php
when i try and use the relative path for the css file: /includes/css/main.css

That's not a relative path, that's an absolute path. Whenever your link starts with a / it's an absolute path. A relative path would start with a file name, folder name (without preceding slash), or ../

As jestershinra said, just remove the / at the front and it should be fine.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.