
wp-config.php is a crucial WordPress core file that contains information about the website’s database (values for the database, database user credentials, and the host).
In this article, I am going to detail the fifteen most common uses of the wp-config.php file so that you could better understand how the WordPress installation works and how you can better leverage the core files for your website performance and security.
- Where Is wp-config.php Located?
- How to Bypass FTP Connection Information?
- How to Enable Debugging in WordPress?
- How to Change Site and WordPress URL?
- How to Increase or Decrease PHP Memory?
- How to Edit Trash Box Timing?
- How to Disable Automatic Updates?
- How to Set Autosave Intervals?
- How to Set Database Prefix?
- How to Enable Multisite Network?
- How to Enable Error Log Configuration?
- How to Turn on WordPress Caching?
- How to Configure Database Settings?
- Redirection of Non-existent Subfolders and Subdomains
- How to Edit Post Revision?
- How to Set a Cookie Domain?
Where Is wp-config.php Located?
A common question among WordPress users, especially for beginners, is “where is wp-config.php”?
The answer is simple, you’ll find this core file in the WordPress root directory, but it depends on the location of the server.
If you’re working on a localhost with a setup like XAMPP, go to xampp→ htdocs → testing. In my case, the site folder name is “testing.”
If you’re working on a live platform, you need to access your live server via an FTP client like FileZilla. Once logged in, go to the public_html where you’ll see the wp-config.php file.
Now that you know where to find this important core file, I will now go into the details of how you can leverage this file for amping up your WordPress experience.
1. How to Bypass FTP Connection Information?
If you are not able to update the WordPress core and plugins to a newer version due to a faulty FTP connection, you can bypass the FTP connection information.
For this, all you need to do is add the following line of code in the wp-config.php file:
define( 'FS_METHOD', 'direct');
2. How to Enable Debugging in WordPress?
Debugging is a good practice for improving the quality of the code in general, and discovering the source of the error and troubleshooting the problem.
To enable the debug mode in WordPress, all you have to do is add the following lines of code in wp-config.php:
define(‘WP_DEBUG’, false); // disable debugging mode by default define(‘WP_DEBUG’, true); // enable debugging mode
3. How to Change Site and WordPress URL?
If you’ve migrated your WordPress site to a new host, changed the domain name or wish to update the URL from HTTP to HTTPS, add the following lines of code in the wp-config.php would do the trick:
define('WP_SITEURL', 'http://www.example.com'); define('WP_HOME', 'http://www.example.com');
An alternative method is to use the SERVER variable that sets these values dynamically.
define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] ); define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] );
4. How to Increase (or Decrease) PHP Memory?
This feature is available in the Cloudways managed WordPress hosting platform, but for those WordPress users not using Cloudways, it can become a headache. PHP memory available for a WordPress application can be set by adding the following line:
define( 'WP_MEMORY_LIMIT', '64M' );
If required, you can set the maximum memory limit:
define( 'WP_MAX_MEMORY_LIMIT', '256M' );
Note that Cloudways users do not have to edit the wp-config file. They can simply change the value in the application settings from the Cloudways Platform.
5. How to Edit Trash Box Timing?
If a user deletes posts, pages, comments, it is sent to the Trash Box where WordPress automatically deletes them after 30 days. To change this duration, you can add the following line to modify this value to suit your needs. In the following example, I have decreased it to 15 days.
define( 'EMPTY_TRASH_DAYS', 15 );
You can even disable the Trash feature completely by setting the value to zero as the value in the above line.
6. How to Disable Automatic Updates?
Automatic updates were introduced as part of the WordPress 3.7 release where minor core releases and translation files are updated automatically. If you want to disable these features, add the following line in wp-config.php:
define( 'AUTOMATIC_UPDATER_DISABLED', true );
If you want to disable automatic updates for your WordPress core (minor and major updates) all you need to do is add the following lines of code in the WordPress config file:
# Disable all core updates:
define( 'WP_AUTO_UPDATE_CORE', false );
# Enable all minor and major core updates:
define( 'WP_AUTO_UPDATE_CORE', true );
7. How to Set Autosave Intervals?
When creating or editing the post, WordPress automatically saves revisions of the post. The default value of the autosave interval is 60 seconds which can be increased or decreased by adding the following line:
define( 'AUTOSAVE_INTERVAL', 180 );
8. How to Set Database Prefix?
When installing WordPress on your localhost setup such as XAMPP, one of the options is to select database table prefix that is stored in the wp-config.php file as:
$table_prefix = 'wp_';
I personally recommend that you change the default prefix as a security precaution.
9. How to Enable WordPress Multisite Network?
If you want to enable the multisite functionality, you need to add the following code to your wp-config.php file.
define('WP_ALLOW_MULTISITE', true);
After adding this code, a new page “Network” will be available in the Tools section of the WordPress Admin.
If you want to learn how to set up a WordPress multisite, here’s a complete guide.
10. How to Enable Error Log Configuration?
Here is an easy way of enabling basic error logging for your WordPress-powered site. Create a file named php_error.log in the directory of your choice and make it server-writable. Next, edit the path in the third line of the following code and place the snippet in the wp-config.php file:
@ini_set('log_errors','On'); @ini_set('display_errors','Off'); @ini_set('error_log','/home/path/domain/logs/php_error.log');
11. How to Turn on WordPress Caching?
Just add the following code in the wp-config.php file to turn on the WP-Cache.
define('WP_CACHE', true);
12. How to Configure Database Settings?
You can edit database connection settings from the WordPress config file and match database values ( name, user, password, and host ) with your hosting database values.
/ ** MySQL settings - Get this information from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'Your database name'); /** MySQL database username */ define('DB_USER', 'Your database username'); /** MySQL database password */ define('DB_PASSWORD', 'Your database password'); /** MySQL hostname */ define('DB_HOST', 'localhost');
Different WordPress hosting providers use different DB_Host values, and Cloudways use ‘localhost’ (localhost is the common DB_HOST value).
One of the most frustrating errors is “Error Establishing a Database Connection.” It usually appears when you have migrated your site, and your wp-config contains old or incorrect database information. Here’s a complete guide to fix the database connection error.
13. Redirection of Non-existent Subfolders and Subdomains
When the visitor tries to access a subdomain or subfolder that doesn’t exist on your website, you can simply redirect your site visitors to a specific page or URL. All you need to do is paste the following line of code into the wp-config.php file.
define( 'NOBLOGREDIRECT', 'http://example.com' );
Don’t forget to replace the “http://example.com” with your website URL.
14. How to Edit Post Revision?
You can disable the post revision feature completely and also set the maximum number of revisions that WordPress can store.
To disable the post revision function, just add the following line in the WordPress config file.
define( 'WP_POST_REVISIONS', false );
To limit the number of revisions, just replace the false value with any integer number. For instance, the following line limits the revisions to just 12.
define( 'WP_POST_REVISIONS', 12 );
15. How to Set a Cookie Domain?
WordPress allows you to set the cookie domain for your WordPress site (for unusual domain setups). Here’s the code.
define( 'COOKIE_DOMAIN', 'www.cloudways.com' );
Wrapping up!
I hope this article helped you understand what wp-config.php file is and how to use this WordPress core file to enable or disable various functions.
If you have any queries in your mind, do let me know in the comments section and I would be more than happy to help you out. In the meantime, just check out our platform and click the start free trial button and make your website 100 percent faster.
Customer Review at
“Beautifully optimized hosting for WordPress and Magento”
Arda Burak [Agency Owner]
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 [email protected]