Not sure how to fix the “WordPress download file instead of opening in browser” error on your website? It’s a common issue which we all get sometimes with our WordPress website.
Recently, one of my friends also encountered with this issue. Whenever someone opens his website, a file named “index.php” got downloaded to their system instead of opening the website on their browsers.
If you’re also getting this issue on your blog, then worry not. Here in this guide, we’ll show you the methods to remove this issue from your website ASAP without any issue.
So without wasting any more time, let’s get started on fixing this issue…
WordPress Download File Instead of Opening in Browser
There are tens of reasons which can cause this issue of downloading files instead of opening in browser. But mainly you get this issue due to poor hosting provider, any deflect in cache plugin you’re using on your website, or you messed up with the .htaccess file.
You don’t have to worry about any of these reasons because we’ll show you the exact methods on how to fix the “WordPress download file instead of opening in browser” error like a pro. 😁
Solution for fixing WordPress Download File Instead of Opening Site
Here is the best method on how to fix the “WordPress download file instead of opening in browser” error without any issue.
1. Update Your Server
First of all, you need to make sure that your server is up-to-date. If your server is not updated then there are chances that it may be a reason for the downloading files instead of opening in browser error.
To fix this issue, you’ll need to check whether your hosting provider has an update available or not. If there is any update available then you’ll need to upgrade/update it as soon as possible.
If your website is hosted on a shared hosting provider, then I recommend you to contact the support and share the issue with them. In most cases, they’ll update and upgrade their server and the issue will fix on your website. But, if your website is hosted on a dedicated server or a VPS server, you’ve to upgrade it yourself using the command I’m sharing below.
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.
Once your server is upgraded using the command I shared above, enter the command I’m sharing below to reboot your server. This command will work on all Linux hosting (i.e., Ubuntu and CentOS).
💡 Pro Tip:
- If you’re not sure which operating system you’re using on your server, then you can use both the commands I shared above to check which one works for you.
2. Uninstall Cache Plugin from WordPress
If updating the server won’t work for you, then you can try uninstalling the cache plugin you’re using on your Website. The most common plugin which causes this problem is WP Super Cache Plugin.
But if you’re using any other cache plugin rather than WP Super Cache, I also advise you to temporarily uninstall them from your server and check if you’re still getting this issue on your website.
How can I Access Admin Panel During this Issue?
In most cases (like the one that happened with my friend), even after getting the downloading file instead of opening in browser issue, his WP-Admin panel works fine and he can easily access the panel by typing https://example.com/wp-admin on the browser.
If your wp-admin panel is still opening, try deactivating and deleting the cache plugin from there. You can also try deleting the plugin file from the SSH panel or cPanel by going into the “public_html > wp-content > plugins” directory and delete them using the “rm -rf plugin-folder-name“.
3. Remove addHandler Code to your .htaccess File
If uninstalling the cache plugin will not solve this issue for you, then again activate the cache plugin and move to the third step here. In this step, you’ve to remove a few lines from your .htaccess file.
Here is the line which you’ve to remove from your .htaccess file.
These lines are addHandler code which is generally added in cPanel based servers and hosting. And don’t worry, removing these lines will not harm your website in any case (only if you removed the correct lines from your .htaccess file).
4. Replace Complete .htaccess File
If removing the lines which I shared above doesn’t work for you, then I strongly recommend you taking a backup of your .htaccess file and delete it from your server and recreate another .htaccess file with the content I’m sharing below.
This is a default WordPress .htaccess file and if you’re getting the file download instead of opening in browser issue due to this, it will solve the issue.
In most cases, this code will surely work for your website. But in case you’re still getting the issue, I recommend you to reinstall WordPress website. You can follow this method to simply reinstall any WordPress version on your website.
5. Change Hosting Provider
If none of the other methods works for you, then I highly recommend shifting to some other web hosting provider. It’s because if your website will remain like this for a long time, then you’ll start to lose your Google ranking, and slowly your website keywords will go down in SERPs.
If you wanted to change your hosting, I recommend GreenGeeks, SiteGround, Cloudways, and Flywheel for people who don’t want a dedicated server or unmanaged VPS server. You can also use the “TheGuideX” coupon on cloudways to get $30 free credits in your account which is sufficient for 3-Months free web hosting.
Frequently Asked Questions (FAQs)
Here I’m sharing some common issues frequently asked by our readers and the solutions to these.
Why File Get Download Instead of Opening in Browser?
We’re not completely sure what causes this issue, but mainly after doing the methods which we shared above, you’ll not face any issues like this in the future.
But most of the time whenever I encountered issues like this, it happens mostly due to the cache plugin or messed up .htaccess file.
What is a WordPress Hardening?
WordPress Hardening is a process in which you will increase security on your WordPress website if you’re facing any exploits. For that, there are lots of scripts and tools available on the Internet to increase WordPress security.
What Will you Prefer for Caching Your Website?
Mostly I prefer using WP Rocket on my website along with a CloudFlare cache. The WP Rocket plugin works flawlessly and you’ll never encounter any issue like this after using WP Rocket as your cache plugin.
Conclusion
So if you are also here due to your PHP file is downloading instead of executing, then I hope you guys have found these techniques as useful as I did. Issues like this are very common with WordPress and these are some of the best ways which I personally prefer to fix issues like this and it works like a charm for me.
And the last thing which I recommend is to always update your system and use only the official plugins for WordPress to avoid errors like this.
If you know any other ways to solve this issue, do let me know in the comment section below.