Solved

Website not finding calling index.php

Posted on 2007-03-24
8
252 Views
Last Modified: 2013-12-13
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: http://www.skynet.ie/~geronimo
 When I click on a link though it only picks up the webhost http://www.skynet.ie 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 http://www.skynet.ie/ and sometimes it sees
http://www.skynet.ie/~geronimo

Cheers Dave



0
Comment
Question by:9703403
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 14

Expert Comment

by:Aamir Saeed
ID: 18786537
try giving path

http://www.skynet.ie/~geronimo/

i.e. trailing slash
0
 

Author Comment

by:9703403
ID: 18786582
Where should I set that though ?

When I load
http://www.skynet.ie/~geronimo/
it auto calls the index.php but if I cliick on a link it thinks its http://www.skynet.ie
0
 
LVL 14

Expert Comment

by:Aamir Saeed
ID: 18786594
where you are clicking the links
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 18786597
>> When I click on a link though it only picks up the webhost http://www.skynet.ie 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.

bol
0
Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:9703403
ID: 18786656
Okay code is here and website is here:   http://www.skynet.ie/geronimo/index.php
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  http://www.skynet.ie/?a=authors
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 ?


0
 
LVL 24

Accepted Solution

by:
glcummins earned 250 total points
ID: 18786664
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 "http://www.skynet.ie/". It is shorthand for the following:

 http://www.skynet.ie/?a=authors

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

 /~geronimo/?a=authors

This is shorthand for:

 http://www.skynet.ie/~geronimo/?a=authors

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.
0
 

Author Comment

by:9703403
ID: 18786700
Omg Thanks a million. How simple was that. I feel stupid :(

Appreciate the help. Cheers Dave

0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 18786705
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.

bol
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now