If the virus scanner on your hosting detected a virus in the index.php file on your WordPress website, it is a real big reason to worry. It will adversely impact your website performance and you need to get rid of the virus as soon as possible. As with some other virus you can’t just delete the index.php file as your WordPress website will not work with it.
What is this Virus in index.php file –
How to Disinfect index.php file of Virus –
Directly deleting this file doesn’t work in this case as it is the core file of the WordPress system and removing it will crash your website down. There are two ways you can disinfect your website of this virus in your index.php file.
Method 1 – Replacing it with a fresh index.php file from the similar version of WordPress – As this file doesn’t contain any running data so it can be replaced with a fresh file. Follow the steps to do this :
- Go to your file manage from cPanel or FTP account
- Reach to the installation directory of WordPress, usually it would be public_html
- Look for index.php file and delete it
- Download the fresh copy of similar version of WordPress from wordpress.org
- Unzip the downloaded files and look for index.php
- Upload only the index.php file in the same directory from which you deleted it.
- Done. Your website should be working fine now.
- Also run the virus scanner once just to be double sure.
Method 2 – Removing malicious code from index.php file – You can also remove the malicious code from index.php file. Follow the steps :
- Go to wordpress.org and download the fresh copy of the similar version of WordPress and unzip it.
- Open the index.php file from the freshly downloaded copy on your local system and on the server in file manager.
- Compare both files to find out the extra lines of code in the server’s copy.
- Once you find these extra lines, delete them.
- Run the virus scanner again.
- If it doesn’t detect your index. php file as virus this time, it is done.