What Is The wp-config.php File?

One of the most important files in WordPress installation is the wp-config.php file. This file is located in the root of the WordPress file directory and contains the website’s base configuration details, such as database connection information.

It is a configuration file that contains the following things.

1: WordPress stores database information in the wp-config.php file.

Name of the database for WordPress

MySQL database username

MySQL database password

MySQL hostname

2: Authentication Keys and Salts.

Authentication unique keys and salts are security keys that help improve the security of the WordPress site. These keys provide strong encryption for user sessions and cookies generated by WordPress.

3: WordPress Database Table Prefix

By default, WordPress adds the wp_ prefix to all the tables created by WordPress. It would be best if you changed your WordPress database table prefix to something random. This will make it difficult for hackers to guess your WordPress tables and will save you rom some common SQL injection attacks.

Following are some use of the wp-config.php file.

1: WordPress Debugging Mode.

By default, WordPress hides all notices generated by PHP when executing code. Simply setting the debug mode to true will show you these notices. This provides crucial information to developers to find bugs.

define('WP_DEBUG', false);

2: Changing WordPress URLs Using wp-config.php File.

We can also change the WordPress website home and site URLs using the wp-config.php file. Simply add below two lines to your wp-config.php file:



3: Change Uploads Directory Using wp-config.php

By default WordPress stores all your media uploads in /wp-content/uploads/ directory. If you want to store your media files in another location, you can add this line of code in your wp-config.php file.

define( 'UPLOADS', 'wp-content/media' );

4: Disable Automatic Updates in WordPress

Adding this single line of code to your wp-config.php file will disable all automatic updates on your WordPress site.

define( 'WP_AUTO_UPDATE_CORE', false );

Note: It is recommended that you don’t mess with this file unless you have absolutely no other choice.


Following is the sample code of the default wp-config.php file.




* The base configuration for WordPress*

* The wp-config.php creation script uses this file during the

* installation. You don't have to use the web site, you can

* copy this file to "wp-config.php" and fill in the values.

* This file contains the following configurations:

* * MySQL settings

* * Secret keys

* * Database table prefix



* @link https://codex.wordpress.org/Editing_wp-config.php


* @package WordPress


// ** 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');

/** 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', '');


 * 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');



* 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_';


* For developers: WordPress debugging mode.

* Change this to true to enable the display of notices during development

* It is strongly recommended that plugin and theme developers use WP_DEBUG

* in their development environments

* For information on other constants that can be used for debugging,

* visit the Codex.


* @link https://codex.wordpress.org/Debugging_in_WordPres


define('WP_DEBUG', false);

/* That's all, stop editing! Happy blogging. */

/** 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');

Was this answer helpful?

« Back