Website not finding calling index.php

Hi Okay, hard to explain this.

I have a php script index.php,  which loads some html and when you select a link it calls itself (index.php) passing in for example /?a=authors. I then switch($_REQUEST["a"])  based on the param i set.

The problem is this: My web account is on a shared machine and I have an acount on this with a public_html folder as follows:
 When I click on a link though it only picks up the webhost and not my accuont.
So it does not find the index.php.

I bascially need a bit more info on how you can make my php code knows where it is in relation to iself. I.e sometimes it sees the calling page as and sometimes it sees

Cheers Dave

Who is Participating?
glcumminsConnect With a Mentor Commented:
The problem is caused when you use a link like this:

<a href="/?a=authors">Link</a>

When you start the url with a slash ('/'), you are telling the webserver to get the document from the very top level of the current webserver. In your case, that would be "". It is shorthand for the following:

Obviously, that is not the location you intend. Instead, in the link you need to use:


This is shorthand for:

which will call your index.php script. Just make sure to include your subdirectory in your link href, and you will get to the correct location.
Aamir SaeedCommented:
try giving path

i.e. trailing slash
9703403Author Commented:
Where should I set that though ?

When I load
it auto calls the index.php but if I cliick on a link it thinks its
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Aamir SaeedCommented:
where you are clicking the links
b0lsc0ttIT ManagerCommented:
>> When I click on a link though it only picks up the webhost and not my accuont.

What is the code that does this?  The question and what is happening still isn't clear and you code will help.  I agree that this maybe hard to explain but maybe reread the post to see if there is something obvious to clear up.

9703403Author Commented:
Okay code is here and website is here: 
When you click for example on the authors link i have is set so it passes in /?a=authors
But if you hover over the link you can see
it is it has left out the ~geronimo/index.php
So I get a missing page problem. Why wont it pick up the full url ?

9703403Author Commented:
Omg Thanks a million. How simple was that. I feel stupid :(

Appreciate the help. Cheers Dave

b0lsc0ttIT ManagerCommented:
The suggestion above may be all you need but it would still mean the URL in specific to the page and not relative.  Leave the trailing slash off.  The URL isn't even really valid since it doesn't have a file name.  I suggest you would simplify it if you just used ...

href="<?php= $_SERVER["PHP_SELF"] ?>?a=authors

The result will be a correct, relative url no matter where the page is.  In other words the same script could be used in the page in either directory.

Let me know if you have a question or need more info.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.