Php – XAMPP problems with PHP5

PHPxampp

I enabled PHP5 on my website and my webhost needs me to add the following to .htaccess files for PHP5 to work:

AddHandler application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml
AddType application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml

Locally, I am running XAMPP to develop code, but XAMPP does not want to work with the .htaccess file above.

I think it is an issue with XAMPP not recognizing php5 (but it does recognize php if I use "application/x-httpd-php" instead of "application/x-httpd-php5")

How do I resolve this?! I need the .htaccess files to look like above so they work with my webhost, but I need XAMPP to work locally with the same files without making changes!

Best Answer

Apache has <IfDefine> directive. You can use it to hide AddType from your own server:

<IfDefine !MyServer>
AddType application/x-httpd-php5 .php5 …
…
</IfDefine>

And start apache with

apachectl -D MyServer
Related Topic