Page 1 of 1

Apache's Mystery Behaviour

Posted: Wed May 14, 2003 5:31 am
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?

Posted: Wed May 14, 2003 6:33 am
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.

Posted: Wed May 14, 2003 7:03 am
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?

Posted: Wed May 14, 2003 7:10 am
by volka

Posted: Wed May 14, 2003 7:32 am
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 :)