NYCPHP Meetup

NYPHP.org

[nycphp-talk] Making URLs Search Engine Friendly - Follow Up

ophir prusak prutwo at onebox.com
Thu May 23 12:25:25 EDT 2002


You hit the nail on the head.

If you run PHP as a cgi, when you enter http://www.mysite.com/stuff/blah.php?id=5
What is happening behind the scenes is that apache passes the URL / script
path to the PHP cgi executable, and then the cgi takes it from there.
If the script doesn't exist, the php executable chokes since it can't
find the script!
This brings out another disadvantage of using php as a CGI.
Any URL that apache thinks is a php file will be sent to the php cgi,
and will choke if the file does not exist. This means it's very difficult
to catch 404 errors with php file.

> PHP should parse that
> path to the first script it finds and treat the rest as PATH_INFO
> data.... but it doesn't.

Passing a script data via the URL using "/" is a feature that apache
implements, not php itself. I'm sure the PHP tream could implement this
if they wanted to, but I don't think any problems related to running
php as a cgi are high priority ;)

Ophir

---- "Andrew M. Yochum" <andrew at digitalpulp.com> wrote:
> On Thu, 23 May 2002, ophir prusak wrote:
> 
> > As in the nature of yesterday's presentation - does anyone know what
> > error you get and why it doesn't work with cgi versions of PHP ?
> 
> In your apache error log you get a message like:
> [Thu May 23 10:36:46 2002] [error] [client 209.176.7.100] Premature
> end of script headers: /www/cgi-bin/php
> and a 500 Internal server error is shot to the browser.
> 
> I haven't dug around to find out exactly WHY this is, but here's
> what I've gathered from my experience with it. It seems that the
> PHP binary is passed the path of the script to run, which will
> include the PATH_INFO.  So when it tries to execute it, it dies
> because there is no script named that.  PHP should parse that
> path to the first script it finds and treat the rest as PATH_INFO
> data.... but it doesn't.
> 
> Anyone have any more insight into this?
> 
> Andrew
> 
> -- 
> Andrew Yochum
> Digital Pulp, Inc.
> 212.679.0676x255
> andrew at digitalpulp.com
> 
> 
>  



More information about the talk mailing list