How to Fix “WordPress Download File Instead of Opening in Browser”

Managing WordPress is a huge task in itself, and it’s not uncommon to face glitches on the go. One of the most common ones is when you open a WordPress file and instead of opening it in the browser, a file named “index.php” downloads on your system. My cousin faced this same problem with his website, and how after so many glitches, I went through a lot of solutions that worked well. 

Along with my cousin, this issue is prevalent among my readers too. That’s why I am here to help you all out with a probable solution. Let’s get started without wasting any time.

What Causes This Problem?

Well, before we start huddling through the solutions, we need to understand what’s the main issue behind this. Instead of opening a file, the browser is downloading a file named “index.php”. Mostly, this happens when the website hosting isn’t good enough, or maybe there’s a problem with the cache plugin on your website, or at least say that the .htaccess  file settings are not correct. 

Whatever may be the reason here, you don’t need to worry much about that now.

Solutions to Fix WordPress Download File Instead of Opening in Browser

Below are the right ways on how to resolve the “WordPress download file instead of opening in browser” error without any hassle.

1. Update Your Server

Before hopping onto anything, let’s see if your server is up-to-date. If it isn’t, maybe this is the reason for the problem you are facing. 

In order to solve this issue, verify whether your hosting provider offers an update. In case of any update, you should upgrade it shortly.

Another case might be that your website is hosted on shared hosting. In this case, you need to contact the support and tell them about the problem you’re facing. However, they will mostly update and upgrade their server, which should fix the issue on your site. The scene is a bit different for websites hosted on dedicated servers or a VPS. If so, use the below command to upgrade it:

Cases may be different though for different systems:

For debian-based systems like Ubuntu, follow this command:

For Red Hat Enterprise systems like CentOS, follow this command.

After you have completed upgrading your server with the command I gave above, enter the command I’m giving below to restart your server. This command is compatible with all Linux hosting (e.g., Ubuntu, CentOS).

💡 Pro Tip:

  • If you’re not aware of what operating system your server is running, then you can use both of the commands I presented earlier to see which one works for you.

2. Uninstall Cache Plugin from WordPress 

If your problem is still not solved, we will check if you have issues with the cache plugin from WordPress. In this case, you need to check if there is a cache plugin on your website and then uninstall it. The WP Super Cache Plugin is the plugin that most commonly causes this problem.

If you’re running something different, I suggest that you temporarily uninstall it from your server to see if the problem still exists on your site.

How do you log in to the Admin Panel in this case?

In many situations, being the one faced by my cousin, the WP-Admin panel is available even when the problem concerning “downloading file instead of opening in browser” is present. He can easily access the panel by typing in the browser.

Try to deactivate and delete the cache plugin from there if your wp-admin panel is still operational. Plugin files can also be removed from the SSH panel or cPanel, where you will go to the “public_html > wp-content > plugins” directory and execute the “rm -rf plugin-folder-name” command.

3. Remove addHandler Code to your .htaccess File

This might be the case when uninstalling the cache plugin might not solve your problem. So, if this is true in your scenario, reactivate the cache plugin and follow me now. In this step, you are going to remove a few lines from your .htaccess file.

And this is a line that I want you to delete from your .htaccess file.

These are the wrappers that download handler code and are usually installed in cPanel servers and hosting. No problem as well; deletion of these lines physically will not harm your website at all as long as you are successfully removing those lines from your .htaccess file.

4. Replace Complete .htaccess File

If the method I told you earlier is still not helpful, my suggestion is that first you have a copy of the .htaccess file for a backup. Delete the old .htaccess file on your server.

Right after that, you can have a new .htaccess file and you can just copy and paste the details I have given you right now.

This is a default .htaccess denied file, and due to it, you can download the file as a file, but do not open it in your browser. The error will be fixed after making relevant changes.

Most often, that will undoubtedly work for your site. If the problem still continues, I suggest you reinstall the WordPress site. This approach will just replace the current WordPress version with any other previous version you desire on your website.

5. Change Hosting Provider

If you didn’t find the other ways quite beneficial, then I suggest you move to some other web hosting provider. This is because your website will still be like that for a long time and you will start to lose your Google ranking, and gradually your keywords of your website will get down in SERPs.

If you wish to change your hosting, I suggest considering GreenGeeks, SiteGround, Cloudways, and Flywheel if you do not want a dedicated server or an unmanaged VPS server. The “TheGuideX” coupon can also be used on Cloudways to give you $30 free credits, which are enough for three months of free 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 are not entirely sure what causes this problem, but mostly, after performing the above methods, you will not suffer from these problems in the future.

However, in most cases, when I come across such problems, it usually occurs mostly as a result of cache plugin or corrupted .htaccess file.

What is a WordPress Hardening?

WordPress Hardening is a technique that can enhance the security level of your WordPress website if you’re experiencing some exploits. The scripts and tools for improving security are all over the web.

What Will You Prefer for Caching Your Website?

I mostly use WP Rocket on my website and a CloudFlare cache. The WP Rocket plugin works perfectly and you won’t encounter such a problem when you use WP Rocket as your cachers.


I hope that the solutions I discussed above prove helpful to you as they did to me. Problems like these are quite common when handling WordPress, and you don’t need to panic in these situations. After all, it only helps you optimize your website more. These were some of the best ways that I personally use for my convenience, and they always work for me.

A small piece of advice from my end–always update your system occasionally and avoid using unofficial plugins on your WordPress to avoid errors like these. If you’re aware of any different methods to solve this problem, let me know in the comment section below.

Sunny Kumar

Number of posts: 145

Hi, I'm Sunny Kumar, a passionate tech enthusiast and a blogger from New Delhi, India. With a degree in IT from IIT-D and expertise in SEO, Cloud Computing, Telecom & Networking, and CEH, I specialize in various technical fields, including SEO, WordPress Development, and PC Building. And being a proficient WordPress user, I’m dedicated to delivering quality content and a remarkable user experience.

2 thoughts on “How to Fix “WordPress Download File Instead of Opening in Browser””

  1. Great article, Sunny! Your troubleshooting steps for WordPress issues are spot-on. They’ve been incredibly helpful in resolving the download error. Thanks!

  2. What’s Happening i am new to this, I stumbled upon this I’ve found
    It positively useful and it has aided me out loads. I’m hoping to give
    a contribution & assist different users like its aided me.
    Good job.


Leave a Comment