SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    May 2005
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    relative & absolute paths

    I am having trouble with which kind of path to use.
    The local site folder I am using is nested two levels under the root www folder in wamp. I am not being able to set up the links to work from the includes folder so I can test the site locally.
    HTML Code:
    				<nav>
    				         <ul>
    						<li><a href="trial01.php">Home</a></li>
    						<li><a href="/about/about.php">About</a></li>
    						<li>Our home</li>
    						<li>Rates &amp; reservations</li>
    						<li>You might like</li>
    						<li>Photos</li>
    						<li>Contact</li>					
    					</ul>
    				</nav><!-- end nav div -->
    The other problem I am having related to this is the image not showing up locally on IE but working in FF but they do display on IE when posted live.


    Hopefully that makes sense.

  2. #2
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,888
    Mentioned
    122 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by marioo View Post
    I am having trouble with which kind of path to use.
    The local site folder I am using is nested two levels under the root www folder in wamp. I am not being able to set up the links to work from the includes folder so I can test the site locally.
    HTML Code:
    				<nav>
    				         <ul>
    						<li><a href="trial01.php">Home</a></li>
    						<li><a href="/about/about.php">About</a></li>
    						<li>Our home</li>
    						<li>Rates & reservations</li>
    						<li>You might like</li>
    						<li>Photos</li>
    						<li>Contact</li>					
    					</ul>
    				</nav><!-- end nav div -->
    The other problem I am having related to this is the image not showing up locally on IE but working in FF but they do display on IE when posted live.
    Moved to the "Website design" folder, because it isn't a PHP issue.

    There are three types of URL referencing - absolute, relative and root. I think you're trying to choose between relative and root, not absolute.

    Absolute - the full and complete URL for the resource, as it would appear in the address bar or a link from an external site, eg http://website.com/folder/file. You should use this whenever you are linking to external sites, or giving links that could be taken off-site, but there's no need to use them for internal links most of the time. (Note that different subdomains will count as 'external' for this purpose)

    Relative - historically the most common form of internal linking, this is relative to the position of the current file. This is often the easiest and shortest way to give a URL, although in complex hierarchical structures it can get confusing.

    Root - a link along the lines of /folder/file, with a / at the beginning, is always parsed relative to the domain root. This is useful when you have resources such as stylesheets and images that are stored in a single folder and shared across the whole site – much easier to remember that it's /images/arrow.png than using relative references and trying to remember how many folders deep you are. It's also common in any menu that is included (such as by SSI or PHP), because the menu needs to give the same results no matter what folder the file that is calling it is located in.

  3. #3
    SitePoint Addict
    Join Date
    May 2005
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    Thanks for the info, good to review.
    The reason I thought it might be a php issue is because the page displays locally as a .html file (5) but not as a .php file.
    Sorry I didn't say that above.
    Why would it make a difference?

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,203
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    the page displays locally as a .html file (5) but not as a .php file.
    How are you accessing those files locally? You can't just double click them. You need to access them through your browser, with a specific URL.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •