www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 18

Thread: can't go back to the root index.php

  1. #1
    Join Date
    Jul 2014
    Posts
    7

    can't go back to the root index.php

    Good day everyone,
    Am trying to create a site, inside my root folder I have index.php , and some folders, in each folder it has its own index.php file, but I don't the exact php function I can use to go back to the root index.php Is there any script, or function that will direct my home link back to the root index folder, irrespective of any number of folder ahead it.
    Thanks in advance.

  2. #2
    Join Date
    Dec 2011
    Posts
    163
    Why don't you use an absolute URL?

  3. #3
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    851
    How are you trying to do it now?

  4. #4
    Join Date
    Jul 2014
    Posts
    7
    Thanks for replying
    On my root folder I created folders called college, in this folder there is an index.php, and I included my header.php on the college(index.php),likewise on the main site index.php. Each time I click on the home link that's on the header.php it does not go back to the main root index.php, rather it stops at the college (index.php)........ I ill like to make it dynamic, such that irrespective of anywhere I included the header.php, I can just click on home link andd goes straight to the main index.php.

  5. #5
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    851
    I'll say it again - which I Hate Doing:

    How are you doing it now?

  6. #6
    Join Date
    Mar 2012
    Posts
    1,740
    Assuming you are using code something like this:

    HTML Code:
    <a href="index.php">home</a>
    To call the index.php in the root directory amend it to:

    HTML Code:
    <a href="/index.php">home</a>

  7. #7
    Join Date
    Jul 2014
    Posts
    7
    Quote Originally Posted by jedaisoul View Post
    Assuming you are using code something like this:

    HTML Code:
    <a href="index.php">home</a>
    To call the index.php in the root directory amend it to:

    HTML Code:
    <a href="/index.php">home</a>
    Thank you . Doing that goes straight to my wampserver index.php, how will I make it go to the folder am working on ? .

  8. #8
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    851
    Don't you know anything about 'paths'???

  9. #9
    Join Date
    Mar 2012
    Posts
    1,740
    Quote Originally Posted by sokoya_philip View Post
    Thank you . Doing that goes straight to my wampserver index.php, how will I make it go to the folder am working on ? .
    Your question does not make sense. So I'll answer what I think you meant... To run the index.php in the college folder, from the root, use something like:

    HTML Code:
    <a href="college/index.php">college</a>
    Note: There is at least three other ways of doing it, but I think this syntax is the mot helpful...
    Last edited by jedaisoul; 07-28-2014 at 04:43 PM.

  10. #10
    Join Date
    Jul 2014
    Posts
    7
    Well, thank you very much. I guess no one understand me. You have been of help though. Peace.

  11. #11
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    851
    And you apparently don't understand us. I've asked twice how your code currently looks, but you haven't bothered to show us. Why is that?

    Are you in fact using anchor tags to get to a different page? Or are you using header commands? Either way you need to understand how paths work and simply structure your request to the target file with the correct path.

  12. #12
    Join Date
    Dec 2011
    Posts
    163
    Quote Originally Posted by Dragonfire2008 View Post
    Why don't you use an absolute URL?
    Just in case you don't know...

    ABSOLUTE URL = "www.google.com/maps/index.php"

    RELATIVE URL = "maps/index.php" (assuming you click the link from google.com folder

  13. #13
    Join Date
    Jul 2014
    Posts
    7
    I have a file called header.php there Is a link called that its suppose to always take the user to the root index.php I.e <a href="index.php>Home</a>, still on the root folder, I created a folder called college . The college folder has its own index.php, college.php and the header.php is included on it each of this page,
    While on the root folder an I click on the home button, it directs to me to the home page (perfect) but when am on the college.php, which it is in the college folder, each time I click on the home button, it does not take me to the main home page rather it is localhost/bethel/college/index.php, but I would like it to take me to localhost/bethel/index.php . Is it clear?

    How do I define an absolute path irrespective of any file am working on??

  14. #14
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    851
    absolute MEANS 'irrespective of any path you are in'.

    Code:
    <a href='/index.php'>Home</a>
    <a href='/college/index.php'>College</a>
    The leading / means "starting at the root folder" and '/college' means the folder named 'college' under the root folder.

  15. #15
    Join Date
    Jul 2014
    Posts
    7
    Thank u very much I appreciate .

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles