ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Relative Links v. Global Links (full URL)

January 21, 2011 1:17am

Subscribe [2]
  • #1 / Jan 21, 2011 1:17am

    nitecode

    20 posts

    I am integrating expression into an existing site:

    see related post: http://ellislab.com/forums/viewthread/177954/

    I am starting to run into linking problems. My new instal of EE is in a sub directory many shared resources are not(css, images etc).So I have been writing links with the “../” prepended, but when I navigate to “url/sub_dir/template_group/template.html” none of the resources from the “../” links work.

    Feels like I am missing something very basic about how EE works. I would rather not have to write all my links as “http://www.mysite.etc”. Anybody lend a hand here?

    Thanks,
    -nc

  • #2 / Jan 21, 2011 1:27am

    Cheif

    626 posts

    2 approaches, use “/” to get back to the root then “/afolder/asubfolder/thefile.here” or alternatively use a global variable to hold the long winded global URL.

    <link rel="stylesheet" media="all" href="{globalvar}/css/my.css" type="text/css">
  • #3 / Jan 21, 2011 1:52am

    nitecode

    20 posts

    use “/” to get back to the root

    So I would do this “/../”. First slash gets me to ee’s root (http://www.mysite.com/subfolder/), then I use “..” to go to go to the websites root(http://www.mysite.com)? Does the “/” get you to ee’s root from any page in an ee installation?

    thanks for pointing out {globalvar} I will take a closer look at how that works.

  • #4 / Jan 21, 2011 1:58am

    Cheif

    626 posts

    No, “/” used first will always take you back to the HTML root, then propegate it forward using standard “/afolder/asubfolder/thefile.txt”.

    “../” means traverse back/up one level
    “../../” means back two levels.
    “/” means go back to the very beginning regardless of where you are 😊

  • #5 / Jan 21, 2011 3:28am

    nitecode

    20 posts

    That is deceptively simple… I like it. This clarification was notably missing from the ee userguide.

  • #6 / Jan 21, 2011 3:16pm

    Sue Crocker

    26054 posts

    Thanks for the assist, Cheif.

    I just wrote this, but will also add it to the EEWiki.

    EEBeginners:// HowTo Work with Images Inside ExpressionEngine

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases