Useful Configuration Steps for Securing Your WordPress Site

Security Keys:

You don’t have to remember the keys, just make them long, random and complicated that’s it. You can generate a new set of security keys using the WordPress Security Key Generator. You can change these at any time to invalidate all existing cookies. This does mean that all users will have to log in again. Copy the new key and paste it.

MySQL database table prefix:

A table_prefix is placed in front of your database tables. By default, it’s set to wp_, change to something 6dRxWf_ like this. For the securing purpose, please try to change user_table and user_meta_table names. Please remember when you are using table prefix use only numbers, letters, and underscores.

Moving and rename the wp-content folder:

The wp-content directory will store all your theme files, plugin files, and images. Why Move The wp-content Folder The best reason to move the wp-content is for security if you move this to an unexpected location any hackers looking to target this area won’t be able to find it, or it will make it more difficult to find.

Move the WordPress Plugin Directory:

  1. Set WP_PLUGIN_DIR to the full local path of this directory (no trailing slash)
  2.  Set WP_PLUGIN_URL to the full URI of this directory (no trailing slash)

Move the WordPress Theme folder:

You cannot move the themes folder because its path is hard coded relative to the wp-content folder.

Move Uploads Directory:

This path can not be absolute. It is always relative to ABSPATH, therefore does not require a leading slash. Add the define just after this:

Install plugins on localhost:

In some cases, you are not able to update/upgrade your WordPress plugins to a newer version without providing your FTP connection information. This is a common issue whereby the WordPress system can’t write to your /wp-content folder directly.

To solve this issue you need to define the FTP details. So WordPress will remember it. Alternatively, you may also provide WordPress with write access to your /wp-content folder by accessing the FTP root file and changing the folder file permission (CHMOD) to 775 rather than the default 755 and 644.

There is, however, an easier way to deal with this; by defining constant, FS_METHOD in your wp-config.php file. This bypasses WordPress’s recurring prompts and allows auto-updates of your files to happen. And it takes only 1 line of code to do this.

Disable Post Revisions:

Defaults WordPress WP_POST_REVISIONS to true (enable post revisions). If you want to disable the feature, use this setting:

or

Media Trash:

This constant controls the number of days before WordPress permanently deletes posts, pages, attachments, and comments, from the trash bin. The default is 30 days:

WordPress debug mode for developers:

Save queries for analysis:

If “SAVEQUERIES” is true your website performance is getting slow, better we can turn off this if you are not debugging or troubleshooting.

Then in the footer of your theme put this:

PHP Memory:

Compression:

Updates:

Automatic Database Optimizing:

The script can be found at {$your_site}/wp-admin/maint/repair.php

Block External URL Requests

Block external URL requests by defining WP_HTTP_BLOCK_EXTERNAL as true and this will only allow localhost and your blog to make requests. The constant WP_ACCESSIBLE_HOSTS will allow additional hosts to go through for requests. The format of the WP_ACCESSIBLE_HOSTS constant is a comma separated list of hostnames to allow, wildcard domains are supported.

Cleanup-Image Edits:

By default, WordPress creates a new set of images every time you edit an image and when you restore the original, it leaves all the edits on the server. Defining IMAGE_EDIT_OVERWRITE as true changes this behavior. Only one set of image edits are ever created and when you restore the original, the edits are removed from the server.

Override of default file permissions:

View All Defined Constants:

it returns an array of all the currently defined constants with their values.

Vijayan J

Thanks for stopping by guys! I’m Vijayan and Techpulse is my beloved brainchild.
Currently working as a PHP developer in a digital marketing start-up, I’m overly passionate about not just learning new things but also putting those into practice. I swear by a quote I once came across…
‘What separates successful people from unsuccessful people is the former’s ability to execute’.
Feel free to reach out to me if you have any questions, suggestions or feedback. Hoping to see more of you here!