Just to re-enforce Michael Sims, post... * Thus wrote KEVIN ZEMBOWER: > I'm a system administrator who's dabbled a bit in PHP, but am not very experienced > in it. My PHP developer came to me with a behavior which neither of us can > understand. > > If you go to this URL, you'll get a broken version of the main home page on our > site: http://www.hcpartnership.org/index.php/search . We can't understand this, > because 'index.php' is a file, not a directory. (The correct web page is just at > http://www.hcpartnership.org/index.php.)
This behaviour has been around (cept for iis & php) since way back in the CERN httpd days. traditionally this behaviour was only known within your cgi-bin directory. But since php is ran in your document root, the behaviour has changed. The original behaviour was to issue something like: /cgi-bin/script.cgi/path/to/some/random/thing And the CGI script would be passed two extra environment variables: PATH_INFO PATH_TRANSLATED PATH_INFO would contain the string after the name of the cgi being executed PATH_TRANSLATED would be DOCUMENT_ROOT/PATH_INFO. If you followed all that I said so far, the cgi application, with super ease, could check and read a file that actually existed in the normal html document tree. Which made writing C programs a lot more easier :) > > Here's another example: > http://www.hcpartnership.org/path_test.php/search : does not generate a 404 error > http://www.hcpartnership.org/path_test.html/search : generates a 404 error Apache is smart enough to determain the difference between a .html and php script. PHP simply inherits the traditional CGI environment, and an html simplyy can't do anything with PATH_INFO, so apache just decides to say 404. > Can anyone explain to me why this is happening? Is this a danger? Can this be turned > off? Is this controlled in the .php code, in the php.ini file or in the Apache > configuration, or elsewhere? One quick fix, i could suggest but not recomend is to add an auto_prepend_file in php that checks for $_SERVER['PATH_INFO'] and will redirect to $_SERVER['PHP_SELF']. A better solution, on the other hand, would be just to make sure your html output behaves properly, aka not define a link that goes to /index.php/search. And the best solution, depending on how active and complex your site is, is to use the quick fix and have it alert you in some way, ie using error_log(), as to let you know that you need to fix some html somewhere. > > We didn't even know how to describe this problem well, so our searches of the > archives of this mailing list and Google weren't successful. Let me know if we > overlooked something. > > Thanks so much for your suggestions and thoughts. I just hope my thoughts and suggestions were clear enough :) And that I didn't go overboard. Curt -- First, let me assure you that this is not one of those shady pyramid schemes you've been hearing about. No, sir. Our model is the trapezoid! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php