Apache's Mystery Behaviour

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Gleeb
Forum Commoner
Posts: 87
Joined: Tue May 13, 2003 7:01 am
Location: UK
Contact:

Apache's Mystery Behaviour

Post by Gleeb »

Under Apache/1.3.24 and PHP/4.3.1, I am getting odd behaviour.

I don't need the .php extension. I can go to http://127.0.0.1/test/2, and it'll work just like http://127.0.0.1/test.php/2. Is this normal behaviour, or have I changed something and forgotten? What would I have done to cause this behaviour?
lcidw
Forum Commoner
Posts: 58
Joined: Mon Apr 28, 2003 8:55 am
Location: Netherlands

Post by lcidw »

test.php/ or test/ are two different directories, they're not php files. there could be php files in 2/ and if the name of a php file in there is index.php it will load automaticly, if you configured apache that way.
Gleeb
Forum Commoner
Posts: 87
Joined: Tue May 13, 2003 7:01 am
Location: UK
Contact:

Post by Gleeb »

test.php is a file. I'm taking advantage of the fact that apache will walk backwards through the URI (right term?) to make it use test.php. It just makes URLs a little easier to remember. Here's how it's all set up.

A (pretty) directory listing

Code: Select all

/
|- index.php
|- test.php
|- common.php
|- config.php
|- .htaccess
|
|-/dev/
| |- .htaccess
| |- common.php
| |- config.php
|
|-/images/
| |- iip.gif
| |- logo.gif
|
|-/phpMyAdmin-2.5.0/
| |- Too many for me to type
As you can see, there is no /test/ diectory, nor a /test.php/ directory. In the URL HTTP://127.0.0.1/TEST.PHP/2, PHP_SELF is /TEST.PHP/2, which when explode()ed, it results in

Code: Select all

Array
(
    ї0] => 
    ї1] => test
    ї2] => 2
)
[2] is what I use to interrogate the mySQL database for the correct information.

While I probably went overboard in explaining how my script works, I hope it's a little clearer. I'll reprase my question, if I may.

When I request http://127.0.0.1/test.php/2 I am given all the content for page 2. If I request http://127.0.0.1/test/2 the same happens. Why does this happen?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Gleeb
Forum Commoner
Posts: 87
Joined: Tue May 13, 2003 7:01 am
Location: UK
Contact:

Post by Gleeb »

So, apache will be tracing backwards through the dircetories till it gets there, where the multiview thing causes it to load test.php?

Ah, I get it now ;)

Thanks for your help :)
Post Reply