12 Basic WP-Config Tweaks That You Should Know

by Saud Razzak  April 5, 2017

WP-config.php file is the backbone of entire WordPress installation. Most importantly, this file saves the values for database, database users and their passwords, and the host. It has also been used for handling the security and performances of your WordPress websites.

How to Find WP-Config.php?

So, someone may ask this question, “where to find wp-config.php”? The answer is simple, you will not get this file by default instead you get a sample file named as wp-config-sample.php after installation By using this sample file, you can create the actual wp-config.php and then proceed to setup your WordPress website. This is an automatic process, however, when you paste all the WordPress files to your server using FTP and run the installer, it will ask about your database credentials to create the wp-config file automatically on the root.

In this article, I am going to tell you twelve easy tricks related to this wp-config.php in order to make it more robust.

WP-Config

So without further ado, check out the following steps.

  1. How to bypass FTP connection information?
  2. How to enable debugging in WordPress?
  3. How to change site and WordPress URL?
  4. How to increase (or decrease) PHP memory?
  5. How to edit Trash Box timing?
  6. How to disable automatic updates?
  7. How to set autosave intervals?
  8. How to set Database Prefix?
  9. How to Enable Multi-Site Network?
  10. Error Log Configuration
  11. Turn on WordPress Caching
  12. Lockdown wp-config.php

1. How to Bypass FTP Connection Information?

Bypass FTP connection information on plugin installation or WordPress upgrade by adding following line in wp-config.php:

2. How to Enable Debugging in WordPress?

To troubleshoot the issues, we can enable WordPress debugging by adding following lines in wp-config.php:

The above code will generate a log file in the wp-content directory of your Webroot.

3. How to Change Site and WordPress URL?

Site and WordPress URL can be changed by adding following lines in wp-config.php:

The above code is very useful if you are migrating your site to a new URL because these lines override the values defined in the wp_options table. Another method is to use SERVER variable, which will set these values dynamically.

4. How to Increase or Decrease PHP Memory?

This feature is also available in Cloudways Console, but still it is a big headache for WordPress users. PHP memory can be increased for your WordPress application by adding following lines:

If needed, you can set a maximum memory limit as well using the following code:

5. How to Edit Trash Box Timing?

By default, if a user deletes posts, pages, comments, etc., it is sent to Trash box where WordPress automatically deletes them after 30 days. To change this duration, you can add following line to modify value of days as per your need. In the following example, we have decreased it to 15 days.

You can also disable the Trash feature completely by providing 0 (zero) as value in above example.

6. How to Disable Automatic Updates?

After the release of WordPress 3.7, Automatic Updates was introduced. By default, minor core releases and translation files are used to update. To disable this feature, use the following lines in wp-config.php:

I recommend disabling security updates is not a good idea, however, It totally depends on you to keep it enable or disable.

In addition, by default, automatic updates do not work with major releases, but you can enable any core updates defining WP_AUTO_UPDATE_CORE as follows:

# Disables all core updates:


# Enables all core updates, including minor and major:

7. How to Set Autosave Intervals?

When creating or editing the post, WordPress automatically save revisions of your post. The default value of autosave interval is 60 seconds which can be increased or decreased by adding following line:

8. How to Set Database Prefix?

When you are installing WordPress using the wizard, you can see one of the options is to select the Table prefix. That is stored in the wp-config.php file as:

I personally recommend that you can use something different wp_ for the safety of your website from hackers.

9. How to Enable Multi-Site Network?

You need to know that, WordPress 3.0 WPMU was merged into WordPress core. If you want to enable multisite functionality then you need to add the following code in your wp-config.php file.

After adding this code, there will be a new page in your wp-admin called “Network” located in Tools > Network. Now, you need to follow the directions on that page to continue the setup of the MU Network.

You can also check out the WordPress Official WPMU.

10. Error Log Configuration

Here is an easy way to enable basic error logging for your WordPress-powered site. Create a file called “php_error.log”, make it server-writable, and place it in the directory of your choice. Then edit the path in the third line of the following code and place into your wp-config.php file:

11. Turn on WordPress Caching

Just add the following code in the wp-config.php file to turn on the WP-Cache.

12. Lockdown wp-config.php

As we all know that wp-config.php is one of the most important WordPress files. So, why don’t we hide it to hackers? Wp-config is located in the root WordPress folder by default, but you can move it. To save your wp-config file you need to move outside your public_html directory. If your website is running on Apache Web Server, you can add the following directives to the .htaccess file:

If the website is running on Nginx, you can add the following directive to the configuration file:

If you have any other query in your mind do let me know I would love to add to my article. In the meantime just check out our platform while clicking on the Launch Free Server below and make your website 100% faster.

Make Your WordPress Website 100% Faster.

Host it now on Cloudways WordPress Hosting Platform.

About Saud Razzak

Saud is the WordPress Community Manager at Cloudways - A Managed WooCommerce Hosting Platform. Saud is responsible for creating buzz, spread knowledge, and educate the people about WordPress in the Community around the globe. In his free time, he likes to play cricket and learn new things on the Internet. You can email him at m.saud@cloudways.com

Stay Connected:

You Might Also Like...