Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder mOrloff's Avatar
    Join Date
    Nov 2008
    Location
    The Great Pacific NW, USA
    Posts
    422
    Thanks
    8
    Thanked 6 Times in 6 Posts

    How do I make link-paths work in sub-directories (do I use $_SERVER[]) ??

    I've got my main nav menu defined as a constant to simplify site-wide updates.

    Now I want to add a subdir to the site, and use the same nav.

    Here's an extremely simplified example of the resulting nav menu:
    Code:
    <ul>
        <li><a href="home.php"></a>Home</li>
        <li><a href="about.php"></a>About</li>
        <li><a href="contact.php"></a>Contact</li>
        <li><a href="store/index.php"></a>Store</li>
    </ul>
    How do I make it so that if I'm on a page in the "store" subdir, the links go to the correct dir, and don't try to find them in the "store" subdir?

    I thought it had something to do with $_SERVER[], but I'm not seeing it.

    Thanks in advance.
    ~ Mo
    Last edited by mOrloff; 02-15-2010 at 11:02 PM.

  • #2
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    Use absolute paths:
    Code:
    <ul>
        <li><a href="/home.php"></a>Home</li>
        <li><a href="/about.php"></a>About</li>
        <li><a href="/contact.php"></a>Contact</li>
        <li><a href="/store/index.php"></a>Store</li>
    </ul>

  • #3
    Regular Coder mOrloff's Avatar
    Join Date
    Nov 2008
    Location
    The Great Pacific NW, USA
    Posts
    422
    Thanks
    8
    Thanked 6 Times in 6 Posts
    Oh ... seriously ??
    And here I was, looking for a PHP solution.

    I "learned" that back in the early-mid 90's.
    I guess all this new learnin' is pushing that old info out the hole in the back of my head.

    But seriously, thanks-a-bunch for the help!


  •  

    Posting Permissions

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