SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need Internal Link Switcher

    This is a little hard to explain, but I think it's really a fairly simple problem. I've combined several content management systems into a single CMS. That is, I have five websites online, each of which is a CMS, but most of the files are stored in just one website on my computer.

    Consider the following folder structure:

    C:/sites/geobop/
    Animals
    Topics
    Reference
    ...where every site has folders named Topics and Reference. If I want to display GeoZoo Reference locally, I just change the value of $MySite from $MySite = 'Geobop' to $MySite = 'GeoZoo."

    But I'm now experimenting with a new scheme where I won't have to change values; I'll just give each site its own folders.


    C:/sites/geobop/
    Topics
    Reference
    GZ
    Animals
    Topics
    Reference
    The new folder, GZ, represents GeoZoo, and it contains all the folders found in the online version of GeoZoo.

    The problem is that I can no longer preview GeoZoo pages locally at http://geobop/Topics. Instead, I have to type in http://geobop/GZ/Topics. It isn't that big a deal, but all my links point to URL's sans "GZ."

    Is there something I can do to automatically insert "GZ/" after geobop in all my local links without affecting my online links?

    Thanks.

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    /* Get the name of this server */
    $server strtolower ($_SERVER["SERVER_NAME"]);

    if ( (
    substr_count ($server'localhost') == || substr_count ($server'127.0.0.1') == ) {
        
    $prefix "GZ/";
    } else {
        
    $prefix "";
    }

    echo 
    '<a href="'.$prefix.'pagename.php">A page</a>'
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I'll give that a try.

  4. #4
    SitePoint Zealot
    Join Date
    Sep 2004
    Location
    Boston
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mod_rewrite!

  5. #5
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    If he's running Apache as his localhost.
    Ian Anderson
    www.siteguru.co.uk


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
  •