PHP files downloading instead of executing.

Avatar
  • Answered
My account was recently downgraded from a dedicated account to a VPS account. I've just discovered that the primary domain on my account (circa75.co) is having issues with with PHP files. Instead of PHP files executing, they are downloading. I've uploaded a test index.php file for testing purposes.
Duplicates 1
index.php downloading instead of opening in browser

My website is working fine, apart from the fact that when ever I try to open domain/rss instead of the browser opening the feed, it tries to download it.


I tried fixing it by altering .htaccess, but that didn't seem to work.


Has something changed on the server side that would account for this problem?


Chris

Avatar
-1
Tech Bawaal
Quote from BradM
Hi Chris, Whenever I try to open a php file the browser tries to download it instead of loading it normally. I've seen this issue a few times in the past. Most of the time, the problem is due to conflicting code in your .htaccess file. I tested the URL you provided, but I was not able to replicate the issue. I assume that you were able to resolve the issue? One of the things to keep in mind is that .htaccess files are recursive. What this means, is that if your rss folder is located here: /public_html/rss ... all of the following .htaccess files could be affected files in the rss folder: /public_html/rss/.htaccess /public_html/.htaccess /.htaccess I'll assume you were able to resolve this issue, as I tested in several browsers and was not able to replicate the problem. If by chance you are still having an issue, feel free to post a comment at the bottom of this page with more information, and I'll be happy to look into this further. Thanks! - Brad

My htacces file is looking same as the normal htaccess file looks.

Avatar
Tech Bawaal

It is happening with my site techbawaal.com too whenever I open my site it starts downloading a file. I checked the htacces file and it is okay as a normal WordPress org htaccess file seems. My website is malware-free as well. Also tried troubleshooting nothing worked. It is happening with every browser chrome, edge, and all. Please help me out to reach the solution. I also tried clearing cache also opened in incognito mode as well but nothing happened. It happens in every 5-10mins.

Thank You

Avatar
Scott
Hello, Thank you for your question about PHP files downloading instead of executing. This is normally due to an improper handler code. In the .htaccess file, you will want to ensure the handler code matches your version of php. If it does not, the php files may try to download instead of process. To use the default php version on the server, use the following code:
# Use system PHP5 as default
AddHandler application/x-httpd-php5 .php
You may also specify different php versions, depending on your need:
# 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
If any of the above are the default version, then the first code mentioned will be the correct handler. Kindest Regards, Scott M
Avatar
BradM
Hi Chris, Whenever I try to open a php file the browser tries to download it instead of loading it normally. I've seen this issue a few times in the past. Most of the time, the problem is due to conflicting code in your .htaccess file. I tested the URL you provided, but I was not able to replicate the issue. I assume that you were able to resolve the issue? One of the things to keep in mind is that .htaccess files are recursive. What this means, is that if your rss folder is located here: /public_html/rss ... all of the following .htaccess files could be affected files in the rss folder: /public_html/rss/.htaccess /public_html/.htaccess /.htaccess I'll assume you were able to resolve this issue, as I tested in several browsers and was not able to replicate the problem. If by chance you are still having an issue, feel free to post a comment at the bottom of this page with more information, and I'll be happy to look into this further. Thanks! - Brad