Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • sdfsfm 70 posts 94 karma points
    Jul 28, 2010 @ 17:27
    sdfsfm
    0

    CSS/JS/images not showing a level below the root level

    Hi Basically my setup is as follows root >> Home >> products>> a product.

    The url structure looks likes this  http://localhost/sitename/our-products for a list of all the products which displays correctly however when i go through to the actual product http://localhost/sitename/our-products/temporary-product-1/ no images styling or js is shown.This occurs on every sub page, even under the about section

    My images css and js are all in the root level of the site i.e in a css folder under sitename etc. And is called in the masterpage like so <link rel="stylesheet" href="css/styles.css" type="text/css"  />

     

    Any ideas why its not showing correctly?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jul 28, 2010 @ 17:58
    Tom Fulton
    1

    It's because you're using a relative path for the CSS/images/etc.  So it's actually looking for http://localhost/sitename/our-products/temporary-product-1/css/styles.css instead of http://localhost/css/styles.css

    Prefix your paths with a "/" to make them start from the root.  IE  href="/css/styles.css"

    Or, I think "~/" might be the new way of doing it, since 4.5 can run in virtual directories.

    -Tom

  • sdfsfm 70 posts 94 karma points
    Jul 28, 2010 @ 18:03
    sdfsfm
    0

    Hi Tom, that's what i intially thought, so i tried it and it doesn't work. BTW I am running in a virtual directory.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jul 28, 2010 @ 18:05
    Tom Fulton
    0

    Did you try "~/css/styles.css"?  Or as a quick fix you could try "/virtual-directory-name/css/styles.css"

    If not try running an HTTP Capture tool like Fiddler to see where the browser is actually looking for the files and whether or not it's finding them

  • sdfsfm 70 posts 94 karma points
    Jul 28, 2010 @ 18:09
    sdfsfm
    0

    Hi Tom, Yup i did try it out, Firebug it telling me it pointing to http://localhost/sitename/our-products/~/css/styles.css,

    The only way its working so far is ../css/styles.css but then any page above it doesn't work

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jul 28, 2010 @ 18:47
    Tom Fulton
    1

    Even "/sitename/css/styles.css" doesnt work?  In that case I'm kinda stumped, sorry :(

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Jul 28, 2010 @ 18:50
    Stefan Kip
    0

    What is the path of your root page and the path of one of the subpages where it isn't working?

  • sdfsfm 70 posts 94 karma points
    Jul 28, 2010 @ 19:36
  • Stefan Kip 1614 posts 4131 karma points c-trib
    Jul 28, 2010 @ 19:46
    Stefan Kip
    0

    Tom's last post should work: /sitename/css/styles.css

    If it doesn't, look with firebug where it's looking in the Net tab, then select CSS tab underneath and post the full url here...

  • sdfsfm 70 posts 94 karma points
    Jul 28, 2010 @ 20:17
    sdfsfm
    0

    @Tom sorry i missed your post saying using /sitename/css/styles.css, it worked after clearing my cache. Thanks guys

Please Sign in or register to post replies

Write your reply to:

Draft