Apache Downloading PHP Instead of Running

It is very common problem when you transfer some website from one place to another that something doesn’t work. šŸ™‚ For example, today I was transferring one website from Hostgator to my server and noticed that, when I try to open website it tries to download PHP pages instead of loading it. All other websites on the machine were working normally.

If you have problem with PHP files downloading instead of executing, first tip is to take a look at your .htaccess file. The problem mostly occur because your PHP version is not the same at PHP version of old hosting provider.

To use the default PHP version on the server, insert this code at the end of your .htaccess file:

AddHandler application/x-httpd-php5 .php

If you want to specify exact php version, depending on your need you can use:

# Use system PHP5.2 as default
AddHandler application/x-httpd-php52 .php

# Use system PHP5.3 as default
AddHandler application/x-httpd-php53.php

# Use system PHP5.4 as default
AddHandler application/x-httpd-php54 .php

# Use system PHP5.5 as default
AddHandler application/x-httpd-php55 .php

Leave a Reply

Your email address will not be published. Required fields are marked *