I was helping a friend who was migrating a WordPress site from one host to another. After moving the files over to the new hosting provider instead of the files being server as PHP files by the web server a download prompt would pop-up to download a file. It turns out this was caused by the .htaccess file from the initial host (that was transferred along with the other files) not being properly configured for the new host. Here’s the initial .htaccess file:
# Use PHP5.4 as default
AddHandler application/x-httpd-php54 .php
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
Note the AddHandler directive at the top of the file. My attention was drawn to it as the rest of the .htaccess file are the basic directives required by WordPress. This was likely added by the initial host to default .php files to be handled by PHP 5.4. The new host didn’t have support for PHP 5.4, which caused .php files to be mishandled. The issue was resolved by commenting out the line:
# Use PHP5.4 as default
# AddHandler application/x-httpd-php54 .php
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
With this change the site began to function properly.