localhost and relative paths - apache

Discussion in 'Web Design and Development' started by vegaspass00, Feb 16, 2009.

  1. vegaspass00 macrumors newbie

    Joined:
    Feb 16, 2009
    #1
    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
     
  2. jestershinra macrumors regular

    Joined:
    Sep 4, 2004
    #2
    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.
     
  3. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #3
    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.
     

Share This Page