Wordpress website downloads file - with you
How to Fix WordPress Downloading Index.php Instead of Displaying Site
“WordPress downloads a compressed file instead of opening index.php or when i try to access my wp-admin”.
This was a question asked to us by one of our readers and he wanted to know how to solve it.
As I have no idea how was this happening so I kept the question aside in my questions list until it happened with my blog.
So this made me freak out as I lost access to my wp-admin, although I have a daily backup of my blog. But it’s not a choice to restore my blog as its a long list of work to be done and as for others, they don’t have a daily backup.
So just like a normal user I deactivated all my plugins through the backend of my hosting and tried to access the wp-admin, But this didn’t seem to work.
So I tried to restore my website theme to default twenty fifteen but this time so I was out of luck and now I was worried.
I worked fine on my website all day yesterday, but this morning it tried to download the index.php instead of opening it like a browser normally does. .
Now as I know I have tried:
- Renaming my theme to old-[name-of-theme]
- Renaming plugin folder to old-plugins (to disable them all)
- Clearing the cache for Firefox, Safari, and Chrome.
Nothing worked.
I google and found some answers like
delete AddHandler application/x-httpd-php52 .php .php5 .php4 .php3
No idea how that got there! But I got my solution.
Method to Fix
But here’s what I did and It started working within 5 minutes and it was easy.
I accessed my .htaccess in cPanel and also kept a backup in case I messed the config codes. (Please Keep a backup).
If for any reason you can’t find .htaccess on your WordPress installation root directory, then Click File Manager and make sure to tick Show Hidden Files (dotfiles) and click Go.
The .htaccess should show up where wp (wp-admin, wp-content, wp-includes) is installed, which is your WordPress root directory.
I studied the code and I found some extra lines of code messing with my WordPress. I deleted the extra code and it started working.
For those who are not programmers for them follow the steps below:
- Open and edit .htaccess – Have a backup before editing
- Delete all the codes inside it
- Now copy the code below this and paste & save it
- It should be working now, you can access your WordPress admin.
Hope this helps someone, and have a great day!!!
Conclusion
The reason why your index.php is downloaded is that of your caching plugin or feature in your host which adds a few line of codes that makes your WordPress fast as it compresses the file but in some cases, wp-admin is also cached which makes it impossible to access.
So just edit your .htaccess and paste the above code given and your blog is again ready to rock
If you have any queries, feel free to ask below in the comments.
Editorial Staff at BloggerSprout is a team of WordPress experts led by Niraj Kashyap. Page maintained by Niraj Kashyap. For any queries, Visit AskNiraj.com.
-