SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot ameerulislam's Avatar
    Join Date
    Jul 2011
    Posts
    145
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    interesting page refernce issues

    The thing is Lets say I have my core files in a root and the admin panel in admin folder.

    Now I use same sidebar for both.

    The reference to certain files are now as follows

    HTML Code:
    <a href="example.php"> example </a>
    example.php is in the root, and the sidebar as created keeping that in mind first, now when the sidebar is now being used by the admin pages as well.. that reference is trying to access something like this.. www.website.com/admin/example.php where the real link is www.website.com/example.php

    I know I can put in direct link but that's not good practice I know... What is the good solutions for this?

    tx

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,170
    Mentioned
    454 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by ameerulislam View Post
    What is the good solutions for this?
    Code:
    <a href="/example.php"> example </a>
    Easy.

  3. #3
    SitePoint Zealot ameerulislam's Avatar
    Join Date
    Jul 2011
    Posts
    145
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralph.m View Post
    Code:
    <a href="/example.php"> example </a>
    Easy.
    okay thanks, that works when the files are in the root and a directory..

    But does not work with directory and sub-directory. 2 level deep back to one level up.

    example.com/members
    example.com/members/admin

    now if the file is originally in example.com/members and included in example.com/members/admin , and if I put '/' in front of the page it takes

    example.com/members/file.php to example.com/file.php

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,170
    Mentioned
    454 Post(s)
    Tagged
    8 Thread(s)
    Your original question was how to get that link to point to example.php in the root directory from any location in the site. I gave you the answer to that.

    If you are now wondering how to have a universal link to example.com/members/file.php, then that would be this:

    Code:
    <a href="/members/file.php"> example </a>
    The reason for putting the slash at the very front is that it tells the browser to start from the root folder, rather than from the current folder.

    This

    Code:
    <a href="members/file.php"> example </a>
    says "inside this folder, look for a folder called /members/ and then for a file in there called file.php".

    This

    Code:
    <a href="/file.php"> example </a>
    says "go to the root folder and look for a file called file.php".

    This

    Code:
    <a href="/members/file.php"> example </a>
    says "go to the root folder, look for a folder called /members/, and in there look for a file called file.php".

  5. #5
    SitePoint Zealot ameerulislam's Avatar
    Join Date
    Jul 2011
    Posts
    145
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Brilliant, Thanks!

    Quote Originally Posted by ralph.m View Post
    Your original question was how to get that link to point to example.php in the root directory from any location in the site. I gave you the answer to that.

    If you are now wondering how to have a universal link to example.com/members/file.php, then that would be this:

    Code:
    <a href="/members/file.php"> example </a>
    The reason for putting the slash at the very front is that it tells the browser to start from the root folder, rather than from the current folder.

    This

    Code:
    <a href="members/file.php"> example </a>
    says "inside this folder, look for a folder called /members/ and then for a file in there called file.php".

    This

    Code:
    <a href="/file.php"> example </a>
    says "go to the root folder and look for a file called file.php".

    This

    Code:
    <a href="/members/file.php"> example </a>
    says "go to the root folder, look for a folder called /members/, and in there look for a file called file.php".


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
  •