Not sure how to fix the “WordPress download file instead of opening in browser” error on your website in 2024? It’s one of the most common errors which occurs to everyone sometimes while working with WordPress websites.
Recently one of my friends encountered an issue with his blog that “WordPress download file instead of opening in browser,” and there was no proper article on Google on how to solve this issue. So I tried everything possible to solve his issue, and luckily I find out the solution and also the reason why it occurred.
If you are also having issues, such as while opening your website, it’s downloading a file named the download or index.php instead of opening your site, then these fixes will resolve your issue.
So I am sharing all the possible methods which are useful in solving this issue. 😁
Table of Contents
WordPress Download File Instead of Opening in Browser
WordPress Download File Instead of Opening In Browser is a kind of error in which whenever someone visits your website, a file name “download” or “index.php” gets downloaded instead of opening the website in their system.
There are many reasons that can cause this error in your website, but mainly it happened due to a cache plugin malfunctioning or some buggy codes in your .htaccess file.
But don’t worry; it’s an easy fix. So in order to fix this error, I have mentioned step-by-step methods which you need to follow to get rid of the “WordPress download file instead of opening in browser” error.
Solution for Fixing WordPress Download File Instead of Opening Site
Here are the methods on how to fix the “WordPress download file instead of opening in browser” error. Follow each of the steps carefully, and remember that you don’t skip any steps given below. So let’s get started.
1. Update Your Server
If you are using a Cloud service or a VPS (Virtual Private Network), or a Dedicated server, then you must always keep your system up to date. Believe me or not, 30% of the errors only occur due to some outdated system software. So you first need to update your system properly and then restart your server.
In order to update/upgrade your server to the latest version, you need to log in to your server SSH using any terminal. If you are a Windows user, then you can use Putty to login into your SSH., and for MAC users, you can easily use your terminal to log in to SSH. Login to SSH as the root user, or if you don’t have the root, then you need to use sudo root to execute the given commands.
If you are using a Debian-based System such as Ubuntu, then run the command given below.
If you are on any Red Hat Enterprises System, such as Centos, then run the command given below.
After executing the commands, simply reboot your system and check whether the problem persists.
To reboot your system, type the command below in any OS.
💡 Pro Tip:
If you are unsure which operating system is installed on your system, then you can run both commands to check which one works for you. There is no harm in it.
2. Uninstalled Any Cache Plugin from WordPress
If updating your system doesn’t help you to solve your issue. Then you might need to check if you have any cache plugins installed in your WordPress.
If you are using any of the cache plugins, such as WP Super Cache, WP Rocket, W3 Total Cache, etc, then you need to deactivate them and then check if the issue exists or not.
How can I Access Admin Panel During this Issue?
In most cases (like the one that happened with my friend), the WordPress admin panel is usually accessible even after WordPress download files instead of opening in browser issue, so you can easily head on to your WordPress admin panel (https://example.com/wp-admin) and uninstall the plugin.
If somehow your admin panel is also causing the same issue, you need to remove the plugins from the file manager or SSH manually. If you have any file manager (such as cPanel, VestaCP, ServerPilot) on your server, you can use it to remove the plugin, and if you don’t have any file manager installed, then you need to again login into your SSH and delete the plugin.
The plugin is usually located in the “public_html > wp-content > plugins” directory. To delete the plugin use the command “rm -rf plugin-folder-name” (this will work in both Debian and RedHat systems).
If it solves your issue, then you need to check or ask in the forum of the respected plugin for the solution, or you can try any other plugin for the cache.
If this does not solve your issue, enable your cache plugin again and move to the next method.
3. Remove addHandler Code from your .htaccess File
If you are on an apache-based server, you need to remove some of the lines that start with addHandler from your .htaccess file.
Login to your file manager or SSH, just like in the previous step, and open your .htacess file to edit it. If you are using SSH, then you can use Vi or Nano text editor commands to edit the file and remove any of the files which resemble the one given below.
E.g., of addHandler codes
If you have any of these lines in your .htaccess file or any other resembling the above one, you need to delete them from your .htaccess file and check if your problem is solved.
💡 What is addHandler:
In simple words, it instructs Apache to execute any .php file with the interpreter mentioned in the code. This means “AddHandler application/x-httpd-php74 .php” instructs the Apache to execute any file having .php to be executed with php 7.4, so if your system doesn’t have php7.4 installed, then the PHP file will download instead of executing with any other available PHP interpreter.
4. Replace Complete .htaccess File
If removing addHandler codes from your .htaccess file doesn’t solve your issue or if there wasn’t any addHandler code in your .htaccess file, then it’s time to replace the complete .htacess file with the WordPress default htaccess file.
Copy and paste the WordPress Default htaccess file:
This is the default WordPress file that comes at the time of WordPress installation. If there is anything wrong with your current .htaccess file and due to this, you will be getting the error of WordPress download file instead of opening in browser, and it will solve it.
Copy the code above and replace it with everything in your current .htaccess file. After replacing the file, save it and check whether the problem is solved.
If the problem is still there, it might be due to any malware in some WordPress core file. So I might suggest you do a fresh WordPress installation from scratch.
5. Reinstalling the WordPress
Reinstalling WordPress is the last step to solve the WordPress PHP file downloading problem. This problem usually occurs at the frontend, so you might be able to access the WordPress admin panel normally. If so, the case then takes the full backup using a backup plugin such as UpdraftPlus.
After successfully backing up, just delete everything, reinstall a fresh copy of WordPress, and restore your backup from UpdraftPlus.
You can always do the manual backup if you can’t access your WordPress admin panel. You need to make a zip of wp-contents > uploads and your database, and you are ready to install a fresh copy of WordPress.
6. Change the Hosting Provider
If reinstalling WordPress also doesn’t help you, then the only solution left for you is to change your hosting. Even after everything, you couldn’t solve your issue, it’s possible that the issue is due to some malfunctioning in your current hosting.
You can easily find out and repair the issue in your hosting, but if you aren’t a technical person, then it’s pretty hard to do it yourself. So, in this case, I suggest you change your hosting provider. I recommend moving to Bluehost or Digitalocean.
7. Seek Professional Help
So after trying every possible method, if you are still unable to solve the issue, then you need some professional help. You can reach out to us through the contact us page, and our team will help you in resolving the issue quickly.
We have a team of experts who handles such issues on a daily basis so that we will help you properly.
Frequently Asked Questions (FAQs)
Why WordPress Download File Instead of Opening in Browser?
There are several reasons why this error occurred in the first place. You might have a fault in your cache plugin, some codes in your .htaccess file, or even a corrupt Apache server. To solve this issue, you must diagnose the cause and take steps accordingly.
How to Prevent WordPress index.php File Downloading Instead of Opening in Browser Error from Occurring?
To prevent this error from happening, you should always go for a reliable WordPress hosting such as Bluehost WordPress Hosting, where you will get dedicated support or else if you need to host WordPress on your own server, then you need to have proper knowledge of how to handle a server on your own.
Conclusion
So if you are also here due to your WordPress PHP file is downloading instead of executing, then I hope you have found your solution. This issue is more common with WordPress due to various plugins.
This problem is due to a mismatch of the PHP version of your system with that mentioned in the .htaccess or due to some missing system updates.
This is easy to solve the issue in no time. If you don’t want to encounter such errors again, then always keep your system up to date and use only the official plugins for WordPress.
Thanks Sunny for your helpful article, I had same issue but the error happened because I installed AutoSSL without change the site and admin URLs in database (option table) or WordPress setting page in backend
Removed all plugins and themes and still getting the same problem,
Interesting to hear Hazem using AutoSSL, I think I might be having the same issue
Thanks,
Hey Stephen,
Sometimes some plugins also cause this issue due to incompatibility with other plugins or settings of your website. If nothing works for you I will suggest you take the backup of your wp-content folder and database and try reinstalling your wordpress from scratch & restore your backup, it will work 100%.