Have apache choose a php version based on the extension in the url, but with a single file on the filesystem

Posted by Somejan on Server Fault See other posts from Server Fault or by Somejan
Published on 2012-06-25T14:35:37Z Indexed on 2012/06/25 15:17 UTC
Read the original article Hit count: 247

Filed under:
|

I want to configure a local apache server to serve php files with different php versions. In my document root I have phpinfo.php, now if I go to http://localhost/phpinfo.php4, I want to see the phpinfo.php file processed with php4, if I go to http://localhost/phpinfo.php5 I want to see the same file processed with php5.

Note: both php 4 and 5 are already installed side by side, I have no problem configuring apache to treat files that have a .php4 or .php5 extension on the filesystem with the correct php version. What I want is for apache to do the following:

  • If the url-path ends in .php5, serve the file which has a .php extension on the filesystem using the application/x-httpd-php5 handler.
  • If the url-path ends in .php4, serve the same file with the .php extension on the filesystem using the application/x-httpd-php4 handler.

© Server Fault or respective owner

Related posts about apache2

Related posts about php