All of us have probably come across this weird issue where when we try to open a webpage hosted on WordPress, instead of opening the website, it downloads a file named index.php.
This issue has recently caught my attention.
One of my friends has approached me to fix this weird issue, and to be frank, it has taken a lot of effort to find the problem. And when I solved the issue, I thought of writing this article based on my experience.
If you are also facing an issue like this, here is a comprehensive guide on how to fix it.
Let’s get started.
Reasons for WordPress Downloading a File Instead of Opening in Browser
I would suggest that before we go ahead and jump to the solution portion of the article, you might want to take a moment to understand what is causing this issue.
If you experience this issue, it is likely because whenever you open your website, it takes it as a command and downloads a file called named index.php
This means that instead of opening your website in the browser, you now find that you have a completely blank page and a file has been downloaded to your system. This could be due to any of these reasons:
- You have a cache plugin, and it isn’t compatible.
- Any plugin in your website is malfunctioning.
- There is an error in the code inside the .htaccess file.
How to Fix this Error?
After reading a bunch of articles on the internet trying each method by ourselves, and testing if it is right, we have come up with the six most accurate and best steps that you can use to fix the “WordPress Download File Instead of Opening in Browser” error.
Let us see those solutions below.
1. Updating Server
There is a good chance that you have forgotten to update your server because you have been busy and have not done this in the past. If you are currently using an old version, which may have failed by now, you may notice that your WordPress website is downloading files when you try to view it in a new browser.
The first thing you need to do is check if you are using a personal hosting service. If you are using a personal hosting service, you should check the dashboard for any available updates. If there are, then you can update and download them right away.
Here I am sharing an in-depth guide to updating your server.
Moreover, if you are using a shared hosting provider, then it will be better for you to get in touch with them. This will enable you to explain the situation you are experiencing in detail, and they’ll assist you and update the server.
2. Uninstalling Cache Plugin from WordPress
Generally speaking, plugins that deal with caching are one of the most common causes of these errors. So once you have checked the server update and everything is fine, but in case the warning persists, let’s try deactivating any caching plugins such as WP Rocket, Super Cache, and so forth.
But what if your admin panel is not accessible? It seems hectic, right?
Well, mostly, the admin panel is still accessible, and you can use any method for logging in, such as using the link (https://example.com/wp-admin) and deactivating the plugin.
But in case the panel is not available, follow the steps and do it manually:
The first thing you should do is go to the server’s file manager. In the file manager, search for the cache plugin you are using and remove it. If your server doesn’t have a file manager, then log into SSH and delete the cache plugin from there.
You will find the cache plugin in the public_html folder.
In the “public_html” directory, look for “wp-content.” Inside “wp-content,” you will find a folder called “plugins.” Go into the plugins folder and use the command rm -rf plugin-yourcachepluginname
to delete the plugin.
If the problem still happens, you can reactivate your plugin and then move on to the next step.
3. Removing addHandler Code from Your .htaccess File
If you have an Apache-based server, you will find lines in your .htaccess file with a suffix called AddHandler that you need to remove from your list of codes.
The AddHandler code looks like the one given in the below image.
Using SSH, you will need to log in to the server and look for the .htaccess file. You can edit these displayed commands using any command that is compatible with the server or a text editor such as Vi.
As soon as you have removed these codes from your site, you should check your website again and see if it’s fixed. If not, you may want to try the next method.
4. Replacing .htaccess File
If removing the AddHandler doesn’t work for you, you might need to replace the whole .htaccess file and change it to fit your needs.
In WordPress, there’s a default code for the .htaccess file that makes it easier to customize your website. Sometimes, the default code can have errors, which might cause WordPress to download the file instead of opening it in the browser.
So, you may need to delete the .htaccess file from your server completely and create a new one using the default WordPress code.
Here’s what the code looks like for reference:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
In order to do this, you will just need to copy and paste the entire code into your .htaccess file.
It is now likely that the error has been solved, and your website will start opening rather than downloading the file.
5. Reinstalling WordPress
A common problem on the internet is malware, which can be very annoying. If previous solutions haven’t worked for you, it might be because you’re dealing with a serious malware issue.
One of the best ways to fix this is to refresh everything and reinstall WordPress. Don’t worry; reinstalling WordPress is safe as long as you don’t delete any important files from your server. If you’re unsure how to do this, I recommend taking a complete backup of your website first.
6. Changing Hosting Provider
Last but not least, your hosting company might be facing some issues that are causing this error on your website. It’s a good idea to contact them to fix the problem. If it keeps happening, you might need to consider changing your hosting service.
You can also try to fix the issue with your current hosting service, but that usually requires technical skills. If you’re not familiar with the technical side, you might end up causing more problems. From my experience, it’s often better to switch to a different hosting provider rather than trying to fix it yourself.
Frequently Asked Questions (FAQs)
Still have doubts? Here I have compiled a list of a few commonly asked questions for you.
Q. What exactly causes the WordPress Downloads File Instead of Opening in Browser error?
There are a number of reasons for WordPress downloading the files instead of opening in browser error:
- Server issue
- Cache Plugin Incompatibility
- AddHandler Code malfunctioning
- Wrong code of .htaccess File
- Hosting Provider is not good enough
- Malware in WordPress
Q. What if the problem persists even after trying out all the methods mentioned in this article?
If the problem still persists even after trying out all the methods, there is a possibility that you may have missed some steps. The best thing you can do at times like this is to seek professional help. They will exactly pinpoint the problem and solve it for you.
Q. How to know if my WordPress site is downloading files instead of opening in the browser error?
You can check if the file has been downloaded from the “Downloads” folder on your computer. If you see the file in the folder, it means that your site is having this particular error of downloading files instead of opening them in the browser.
Final Thoughts!
If you’re dealing with this problem, these methods can really help you out. Even if you’re not facing the issue right now, it’s a good idea to check things regularly to prevent any problems in the future.
You can always count on these six methods to fix the issue. They are simple and save you time, making it easier to tackle this problem.
I hope this article answers your questions. If you need more help, feel free to ask in the comments!
I found your article thoroughly helpful and well-structured. I can’t emphasize enough how crucial it is to understand the server, plugin, and .htaccess file involvement in resolving this WordPress issue. Thanks for sharing such resourceful insight.