WordPress itself is a very secure platform. However, there’s a some mistakes that many WordPress users make and that can be exploited by potential attackers. In this article, I’m presenting you simple steps for maximum security.
As a rule of thumb, every time the WordPress core or a plugin you’re using has an available update, don’t forget to apply it. Updates bring new features, but also security fixes. Although WordPress has automatic background updates since version 3.7, you should always keep an eye on them, as automatic updates may sometimes fail to complete.
Plugins are also a sensitive part of your WordPress installation. Remember to update them as soon as an update is available.
Pick a random user name
Attackers know that most people are using usernames such as “admin” or the url of their website. By picking a random user name, you’re making their task much more difficult.
It might seem like a obvious tip, but working with WordPress (and websites in general) every day, I can tell you that most people tend to use weak passwords to protect something as important as their own website.
Host your website on a reliable web host
Especially if you’re on a shared server (this is the case of most small websites such as a personal blog), attackers can use corrupted files on the server, even if they aren’t yours, to spread on other websites hosted on the server. This can’t be fully stopped by you alone, this is why you need to be sure that your web host is super serious about security and offers a strong customer support that will always be helpful in case of any problems.
Make regular backups
If a problem happens, it is essential for every developer to have a backup of both your database and files, so you can restore it to your server. Backups can be done manually or using a plugin such as WP Database Backup. Your web host can also make regular back-ups of your website and database.
Use .htaccess to protect wp-login
Password protecting your
wp-login.php file can add an extra layer to your server. Because password protecting wp-admin can break any plugin that uses ajax on the front end, it’s usually sufficient to just protect
To do this, you will need to create a
.htpasswd file. To do so, go to htpasswd generator and follow the instructions. Once you have your file ready, upload it to your server.
Once done, you need to tell
.htaccess where it’s at. Assuming you’ve put
.htpasswd in your user’s home directory and your htpasswd username is mysecretuser, then you put this in your
# Stop Apache from serving .ht* files
<Files ~ "^\.ht">
Deny from all
# Protect wp-login
AuthName "Private access"
require user mysecretuser
If you’re looking for a plugin instead of doing it by yourself, have a look at AskApache Password Protect. Please note though, that it hasn’t been updated in a year. I haven’t tried it myself so I can’t really neither recommend nor not recommend this plugin.
Remove unnecessary error messages
Login error messages are useful, but unfortunately, they can also provide information to attackers.
To get rid of login errors display on your
wp-login.php page, open your
functions.php file and append the code below to it:
add_filter('login_errors',create_function('$a', "return null;"));
Be careful with plugins and themes
Basically, everything a developer adds to your WordPress install (Themes and Plugins) potentially contains vulnerable code. In fact, anyone can write and offer a plugin or theme.
When choosing a plugin or a theme, make sure that:
- You get it from a reliable source, such as the official WordPress.org repositories
- The plugin/theme is well maintained and has been updated recently
- The plugin has a significant number of installs and/or ratings
Premium themes and plugins that you can find available for free might often contain malicious code injected in them. Sure, a premium theme or a plugin is an investment, but the average $60 you’ll spend is a lot cheaper than the help of a developer or security expert to help you with a broken or a hijacked website. Established premium theme/plugin sellers as such as ElegantThemes, ThemeForest or Themify are very serious about security.
Rename your database tables
By default, WordPress uses
wp_ to prefix your database tables. While it can be easily changed when installing WordPress, unfortunately most developers don’t modify the default prefix. It makes it easier for attackers to target your database.
Happily, there’s a handy plugin called DB Prefix Change which allows you to easily change your database prefix from the default
wp_ to something unique and virtually impossible to guess.
Disable file editing
WordPress features a built-in file editor, which can be very useful to edit your theme on the fly. Unfortunately, if an attacker gains access to your WordPress dashboard as an administrator, he will be able to edit your files, and do much damage. For this reason, you might want to disable WordPress built-in file editor and use a regular FTP program to edit your theme files instead.
To do so, simply paste the code below into your
wp-config.php file, which is located at the root of your WordPress install.
Make use of the All In One WP Security & Firewall plugin
The All In One WordPress Security plugin will take your website security to a whole new level. Designed and written by expert developers, it reduces security risk by checking for vulnerabilities, and by implementing and enforcing the latest recommended WordPress security practices and techniques.
Install All In One WP Security from your WordPress dashboard or download it from here.