SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with base tag

    I'm having trouble using the base tag. Here is what I'm doing:

    HTML Code:
    <base href="http://www.mydomain.com/somefolder/" />
    then I'm trying to link to stuff with:

    HTML Code:
    <a href="/link" />link</a>
    What happens is that the above gets turned into 'http://www.mydomain.com/link' which is incorrect instead of 'http://www.mydomain.com/somefolder/link' which is what I want.

    I can fix it by changing the link to either:

    HTML Code:
    <a href="./link" />link</a>
    or

    HTML Code:
    <a href="link" />link</a>
    So... What's going on here? This problem is not browser specific. Everything I can Google about the base tag seems to say you are supposed to start links with a slash / if you are using a base tag.

    Removing the trailing slash from the base href does not affect the problem:

    HTML Code:
    <base href="http://www.mydomain.com/somefolder" />
    It actually causes more problems! What am I doing wrong here??

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    A forward slash "/" at the beginning of a path starts it at the root regardless of the current path or base location.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



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
  •