Not sure how to fix the “WordPress download file instead of opening in browser” error on your website in 2022? It’s one of the most common errors which occurs to everyone sometimes while working with WordPress websites.
Recently one of my friends encountered the 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 occurs.
If you are also having issues such as while opening your website, it’s downloading a file named 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. 😁
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 which can cause this error in your website but mainly it happened either due to a cache plugin malfunctioning or due to 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 it’s important that you always keep your system up to date. Believe me or not but 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 if the problem persists or not.
To reboot your system type the command given below in any of the OS.
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.
How can I Access Admin Panel During this Issue?
In most of the 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, then you need to remove the plugins manually from the file manager or from SSH. 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 at “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 still does not solve your issue, then enable your cache plugin again and move to the next method.
3. Remove addHandler Code from your .htaccess File
If you are on apache based server then you need to remove some of the lines which 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.
Eg, of addHandler codes
If you have any of these lines in your .htaccess file or any other resembling the above one, then you need to delete them from your .htaccess file and then check if your problem is solved or not.
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 which 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 if the problem is solved or not.
If the problem is still there, then it might be due to any malware in some core file of WordPress. So I might suggest you do a fresh WordPress installation from the 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 backup just delete everything and reinstall a fresh copy of wordpress and restore your backup from UpdraftPlus.
In case you aren’t able to access your WordPress admin panel, you can always do the manual backup. You just 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 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 weren’t able to solve your issue then 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 you to move to Bluehost or Digitalocean.
7. Seek Professional Help
So after trying every possible method, 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 daily basis, so 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 need to 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.
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.