.htaccess & PHP

.htaccess & PHP

Posted by: ByteTraveler
Posted on: 2005-11-09 13:51:00

I've properly set-up my .htaccess to accomodate my ErrorDocuments. Testing mydomain.com/missing.html correctly triggers the ErrorDocument 404.

However, I'm seeing something that I've never seen with any other server (and I've configured quite a few).

The ErrorDocument directive doesn't work with PHP files. For example, mydomain.com/missing.php should trigger the same ErrorDocument as the .html example above, but instead, I simply get the message, "No input file specified.," suggesting that PHP is being passed the URL to execute before Apache checks to see that it's valid.

Proper behavior would be for ErrorDocument to work the same, regardless of the extension of the bad URL.

How do I correct this?

Re: .htaccess & PHP

Posted by: kchrist
Posted on: 2005-11-09 15:14:00

Set PHP to run as an Apache module instead of CGI.

Re: .htaccess & PHP

Posted by: ByteTraveler
Posted on: 2005-11-09 16:06:00

You were correct. Thanks very much.

The bummer now appears to be that I can't have both custom ErrorDocument 404 handling, *and* PHP5?

Looks like it's a one-or-the-other proposition.

Re: .htaccess & PHP

Posted by: doeleman
Posted on: 2005-11-09 16:18:00

It should be possible to have custom ErrorDocuments and run PHP as CGI.

See What's the difference between PHP-CGI and PHP as an Apache module? for info (specially the comments).


Tags: htaccess