Posts Tagged ‘mod_rewrite’

Use a global PHP include for your site

Tuesday, December 20th, 2011

Recently I switched from mod_php to FastCGI for serving PHP websites. With all the advantages of being able to run all websites separatly, the drawback is that configuration options like php_value and php_flag in .htaccess or other Apache configurations do not work anymore. There are some hacks that can be loaded as a PHP Module so PHP itself will read .htaccess files, but none of them work quite well. So the other solution is to use ini_set() in a global PHP include file in the very beginning of the PHP application.

Zend Framework applications are quite easy as all request are forwarded to index.php handling all request, so all global settings like include_paths can be handled there. However, with some PHP websites it is quite hard to introduce a common global PHP include file for application that has no single PHP file the application starts with, and it depends on a include_path set with php_value. The solution is to use Apache mod_rewrite to redirect all php request to a single file, proxy.php, that sets the global settings, and runs the original PHP file requested. (more…)