TopSeoTutWordpressThe Best Setting for wp-config.php File in WordPress

The Best Setting for wp-config.php File in WordPress

Best Setting for wp-config.php File in WordPress
Best Setting for wp-config.php File in WordPress

Almost all important WordPress configurations are found in the wp-config.php file. It is an important file that is present in the WordPress site root. When you design and install a WordPress site, the wp-config.php file automatically links with it.

What is The wp-config.php File?

In simpler terms, it is the base for all WordPress operations. A lot of novice web developers don’t customize the wp-config.php file. However, altering this file will let you design fine-tuned, optimized websites.

What is The wp-config.php File?

It is quite interesting to note that WordPress doesn’t include wp-config.php in the download package. Instead, it distributes “wp-config-sample.php” to help beginners.

The sample file will help you create a configuration file during installation. WordPress doesn’t create a default wp-config.php file since its configuration differs from server to server. The best way to reduce or avoid errors would be by creating the file manually.

How to Edit wp-config.php File in WordPress?

By default, the wp-config.php file is found inside the /public_html folder. This is where many other important WordPress files and folders are present. To start modifying it, follow the following easy steps:

  1. Login to Your cPanel.
  2. Navigate to Files Section.
  3. Click on File Manager Icon.
  4. Go to the Root Folder “public_html”.
  5. Right Click on The “wp-config.php” File then Choose Edit.

wp-config.php File Basic Knowledge

wp-config.php File Basic Knowledge

The wp-config.php will help you to improve your website caches, configure themes, and uses plugins, it includes some default important settings that you should understand first.

wp-config.php Database Setting

The file will let you set a database name, username, password for accessing the database, and a hostname for the database server.

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');
 
/** MySQL database username */
define('DB_USER', 'username_here');
 
/** MySQL database password */
define('DB_PASSWORD', 'password_here');
 
/** MySQL hostname */
define('DB_HOST', 'localhost');

wp-config.php Language Setting

Here you can define DB_Collate and DB_Charset for your website. Also, if you don’t intend to work in English (default language), WPLANG will help you set a new value. (In most cases, keep this untouched)

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
 
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

wp-config.php Database Table Prefix Setting

Set here the database table prefix. (In most cases, keep this untouched)

/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = 'wp_';

wp-config.php Authentication Keys Setting

Many powerful keys can be ascertained in the wp-config.php file. This includes the auth_key, nonce_key, secure_auth_key, and logged_in_key.

/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define('AUTH_KEY',         'put your unique phrase here');
define('SECURE_AUTH_KEY',  'put your unique phrase here');
define('LOGGED_IN_KEY',    'put your unique phrase here');
define('NONCE_KEY',        'put your unique phrase here');
define('AUTH_SALT',        'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',   'put your unique phrase here');
define('NONCE_SALT',       'put your unique phrase here');
 
/**#@-*/

wp-config.php Debug Mode Setting

If you would like to enable the debug mode in WordPress, just change false to true but this is only for advanced users (In most cases, keep this untouched)

define('WP_DEBUG', false);

wp-config.php Absolute Path Setting

This setting is to change the default absolute path for the WordPress installation folder. (In most cases, keep this untouched)

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

What Is The Best Setting for wp-config.php File in WordPress?

As you can see from the above setting, the “wp-config.php” is a powerful PHP file in WordPress core files that can easily improve your site performance or hardly take down your site. With this being said, how would you prepare and setup wp-config.php for WordPress installation?

Disable Post Revisions in WordPress Using wp-config.php File

Post revisions are just a copy of your posts stored in the database and you can disable them unless you need them. To disable the post revisions in WordPress, add the following code at the end of the wp-config.php file.

define('WP_POST_REVISIONS', false);

Change WordPress Site URL Using wp-config.php File

WP_SITEURL and WP_HOME will aid in you reducing the total number of calls to the database and thus improving performance. You won’t be able to edit these settings on the General settings page if you used this method.

define('WP_HOME', 'http://example.com');
define('WP_SITEURL', 'http://example.com');

Disable Theme and Plugin Editors Using wp-config.php File

In order to make your site safe and secure, you should disable Theme and Plugin Editors, to do so add the following code at the end of the wp-config.php file.

define('DISALLOW_FILE_MODS', true);
define('DISALLOW_FILE_EDIT', true);

Disable WordPress Auto Update Using wp-config.php File

The advanced users always make custom changes to their websites and the automatic update will override their changes, to disable the WordPress auto-update append the following code at the end of the wp-config.php file.

define('AUTOMATIC_UPDATER_DISABLED', true);
define('WP_AUTO_UPDATE_CORE', false);

Change Upload Directory Using wp-config.php File

If you have a special sub-domain to upload and store your site images, you can easily change the upload directory without a plugin as follows.

define('UPLOADS', 'path-to/custom-folder');

Increase The Memory Usage For Your Site Using wp-config.php File

If you would like to increase the memory usage for your WordPress Site.

define('WP_MEMORY_LIMIT', '4096M');

Fix CloudFlare Infinite Redirects Loop Issue Using wp-config.php File

If you are using Cloudflare as a DNS provider and you enabled Full SSL/TLS encryption, your site may experience an infinite redirects loop issue, to fix it, just enable the HTTPS setting in the wp-config.php File.

$_SERVER['HTTPS'] = 'on';

Fix CloudFlare Infinite Redirects Loop Issue Using wp-config.php File

RELATED ARTICLES

ABOUT THE AUTHOR

Most Popular

Recent Comments