PHP CGI on per-directory basis

How can I run PHP as CGI on a per-directory basis while keeping it running as an Apache module for the rest of a site?

I normally prefer using mod_php over CGI, so I’ve never actually had to do this before, but I’ve now got a situation where I need CGI for one particular application. Converting the entire domain to CGI will break my existing code. The following, in .htaccess in the directory in question, has no effect; phpinfo() still reports that the server API is Apache, not CGI:

RemoveHandler .php AddHandler cgi-script .php Thanks.


If you want useful replies, ask smart questions.

I’m ignorant of such things, but it seems to me that if it isn’t possible to do what you want, perhaps you could setup a fully-hosted subdomain with PHP running in CGI mode.


Simon Jessey
Keystone Websites | si-blog

perhaps you could setup a fully-hosted subdomain with PHP running in CGI mode.

That’s my last resort move, but I’d really prefer to not go that route. Before I do that I may just modify the other sections of the site (it’s not a big site) so that they run under CGI and deal with the inconveniences. Bleh.

This has proven to be a difficult thing to google for.


If you want useful replies, ask smart questions.

Problem solved. All I need is one line in .htaccess:

AddType php-cgi .php

If you want useful replies, ask smart questions.

That’s all it was? If only all problems could be solved that easily.


Simon Jessey
Keystone Websites | si-blog