SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Path Issues

  1. #1
    SitePoint Wizard rbutler's Avatar
    Join Date
    Jul 2003
    Location
    Springfield, MO
    Posts
    1,867
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Path Issues

    Alrighty, let me see if I can explain this and make it make sense. I have a database, with three columns, FileName, Description, and NavigationID-primary key, the whole point to this database is to display a list of textual links pulling from the database, where the FileName column matches up with the actual file on the remote server, description is telling visitors what the link points to. Hopefully that's clear enough.

    Now to my problem. I'm working on a site that has a home page, argument's sake we will call it index.php. I also have sub-directories, example generalinfo/index.php, where index.php is the home page for general info. When I initially pull from my database on the home page of the site all paths are correct, but for example, http://www.domain.com/generalinfo/index.php, when I enter this page, I can't figure out a way to change paths, either to the home page of the entire site or to another directory, like contact/index.php.

    I know you could something like ../ on a Linux server which is what I'm on, but I'm needing this navigation to pull on numerous sub-directories while keeping the same path correct, right now, by clicking on generalinfo/index.php on the home page, when you try to click on contact/index.php on the same page the path is:
    http://www.domain.com/generalinfo/contact/index.php which won't work.

    Any suggestions, ideas would be of great appreciation!
    Ryan Butler

    Midwest Web Design

  2. #2
    SitePoint Member moe333's Avatar
    Join Date
    Jun 2004
    Location
    St. Louis, MO
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now to my problem. I'm working on a site that has a home page, argument's sake we will call it index.php. I also have sub-directories, example generalinfo/index.php, where index.php is the home page for general info. When I initially pull from my database on the home page of the site all paths are correct, but for example, http://www.domain.com/generalinfo/index.php, when I enter this page, I can't figure out a way to change paths, either to the home page of the entire site or to another directory, like contact/index.php.

    I know you could something like ../ on a Linux server which is what I'm on, but I'm needing this navigation to pull on numerous sub-directories while keeping the same path correct, right now, by clicking on generalinfo/index.php on the home page, when you try to click on contact/index.php on the same page the path is:
    http://www.domain.com/generalinfo/contact/index.php which won't work.

    Everything should work if it is relative to your top directory with the homepage.
    From the home page, your links should be:
    "directory/file.php"
    i.e. generalinfo/index.php

    If you are already in a sub-directory, then you navigate to the other sub-directory relative to the home directory:
    ../directory/filename.php'
    i.e. from generalinfo/index.php to go to the index.php file in the contact sub-directory, then the link should be:
    ../contact/index.php

    I hope this helps.

  3. #3
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,692
    Mentioned
    20 Post(s)
    Tagged
    3 Thread(s)
    moe333,

    Quite correct (../subdirectory/filename) -- except for the site's root level (or files in third-level directories).

    The workaround for rbutler would be to store/use the subdirectory/filename so that it could be called directly from files at the root level while subdirectory files would have to prepend "../" ($link = "../".$link). Third level (subdirectory/sub-subdirectory/filename) files would have to prepend "../" twice but this is best handled at the subdirectory level.

    Of course, this can all be avoided by absolute links but it seems that rbutler wants to avoid this route.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


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
  •