Most of the time a website running WordPress is hacked by a silly misconfiguration that could be avoided during its development. That’s the idea of this article: a checklist of actions that you should take to increase the security of any WordPress website.
During installation steps:
- Change the default table prefix
- Do not create an account with username admin. If there is any, create a new Administrator account and delete the old one.
- Use a strong password containing uppercase, lowercase, numbers, and special characters on all accounts.
After installation steps:
- Change Security Key
- Remove or block via .htaccess the files license.txt, wp-config-sample.php, and readme.html
- Disable file edit via wp-config.php by adding the following code
define('DISALLOW_FILE_EDIT',true);
- Prevent directory listing via .htaccess by adding the following code:
Options All -Indexes
Admin Area Security:
- Lockdown the login page for repetitive failed login using (All In One WP Security Plugin)
- Use email address to login instead of username using (All In One WP Security Plugin)
- Rename the URL of your login page using (All In One WP Security Plugin)
- Remove login links from the theme (if not required by the project).
- Make the login error messages more generical (user/pass) by inserting the following code in your functions.php file
function guwp_error_msgs() { // insert how many msgs you want as an array item. it will be shown randomly $custom_error_msgs = array( 'YOU SHALL NOT PASS!', 'HEY! GET OUT OF HERE!', ); // get random array item to show return $custom_error_msgs[array_rand($custom_error_msgs)]; } add_filter( 'login_errors', 'guwp_error_msgs' );
- Disable the WP REST API, if you aren’t using it. (All In One WP Security Plugin)
- Password protect the folder wp-admin.
- Keep WordPress up-to-date.
- Create an Editor account and use it to publish content.
- Install a plugin to check file changes. (All In One WP Security Plugin)
- Scan the website for viruses, malware, and security breaches.
Theme Security:
- Keep the theme up-to-date.
- Delete and remove unused themes.
- Remove the WordPress version from the theme. (All In One WP Security Plugin)
- Download and use themes only from reputable sources.
Plugin Security:
- Keep all plugins up-to-date.
- Don’t edit any plugins core file unless you really need to edit them
- Delete and remove unused plugins.
- Download and use plugins only from reputable sources.
- Think twice before installing a ton of plugins (don’t use a plugin unless you really need it and you can’t get what you want without it).