Switching to mod_php/cgi for subdomains?


I have a “mobile”.mydomain.com subdomain set up which requires the use of php’s “auto_prepend_file” and “auto_append_file” directives to do some content manipulation. Unfortunately on Dreamhost, you can only use those two php functions if you run PHP as an Apache module and not as CGI.

Is there perhaps a way through a root-level .htaccess file to say something like (pardon the syntax):

if (request contains “mobile.mydomain.com”) {
DefaultType application/x-httpd-php
AddHandler application/x-httpd-php .html .htm .php

Anyone? Bueller?


I’m not completely sure about this (because I have not tested it), but my reading of the PHP manual leads me to believe that you can set “auto_prepend_file” and “auto_append_file” values in php.ini and have them work with with PHP-CGI.

While this this is not quite as convenient as setting directives for use with mod_php, it appears to at least be a possibility - and should easily work on a subdomain basis if you configure it to do so. Couldn’t you also just run the subdomain under mod_php and be done with it, or would the mod_php being version 4 present a problem for you?

I don’t know if there is a way to parse the request and set a type and handler conditionally from the result via .htaccess.