DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
VGSources
Blog

WordPress wp-config.php PHP Constants Explained: URLs, Debugging, Memory, Caching, and Security

A practical guide to WordPress wp-config.php constants: URL overrides, debug logs, PHP memory limits, cache drop-ins, security salts and recovery steps.
Length8 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

wp-config.php is the PHP file WordPress loads before the normal bootstrap. It stores database connection details and can define constants that change the site’s URLs, debugging behavior, memory requests, filesystem paths, caching bootstrap, and authentication secrets.

The most important rule is placement: add custom constants before the line usually marked /* That's all, stop editing! Happy blogging. */. WordPress core establishes defaults during startup, but many values are defined only when your configuration has not already defined them.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What wp-config.php does

WordPress reads wp-config.php before loading themes, plugins, and the rest of core. The file normally contains the database name, user, password, host, character set, collation, and the $table_prefix used for WordPress tables. It also contains authentication keys and salts and may define constants that alter how WordPress runs.

Constants are PHP values that are set once with define(). WordPress’s wp_initial_constants() function supplies defaults for many settings, but it does not replace a value that has already been defined in wp-config.php. That is why the same constant can change behavior without editing core files.

Where to place custom constants

Put definitions above the editing marker, before WordPress finishes loading configuration:

define( 'WP_DEBUG', true );

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

Definitions placed after that marker may be too late for the code that needs them. Keep the file valid PHP: use straight quotes, semicolons, and no whitespace or output before the opening <?php tag.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

URL constants: WP_HOME versus WP_SITEURL

These constants solve different URL problems. WP_HOME is the public address visitors use. WP_SITEURL is the address where the WordPress application files live. They are often identical, but they can differ when WordPress core is installed in a subdirectory or when a reverse proxy separates the public site from the application path.

Constant Controls Typical value
WP_HOME Public site address shown to visitors https://example.com
WP_SITEURL URL used to reach WordPress core files https://example.com/wp

A subdirectory installation can use:

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

At runtime, these values override the corresponding settings stored in the wp_options table. They do not rewrite those database rows. If you remove the constants later, WordPress can revert to the database values, which may explain an unexpected URL change during a migration.

When either constant is defined, WordPress displays that value on the General Settings screen and prevents editing the related field in the dashboard. This is intentional: the configuration file, not the settings page, becomes authoritative.

URL mistakes and recovery

Use the exact scheme, host, and path that the site should serve. A wrong scheme can create HTTP-to-HTTPS redirects that never settle; a wrong host can redirect visitors to another domain; and a missing subdirectory can break CSS, JavaScript, images, login links, or REST requests.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Confirm the public address and the actual location of the WordPress installation.
  2. Set WP_HOME to the public address and WP_SITEURL to the application address.
  3. Clear browser and proxy caches, then test the front page, login page, dashboard, media URLs, and a REST API request.
  4. If the site becomes inaccessible, edit wp-config.php through hosting file access or SSH and correct or temporarily remove the definitions.

Debugging constants and safe error reporting

WP_DEBUG enables WordPress debug mode. It is intended primarily for development and staging copies, where notices, warnings, deprecated-code messages, and PHP errors can be investigated without exposing them to visitors.

Logging and display are separate controls. A practical development or staging configuration is:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
define( 'SCRIPT_DEBUG', true );
Constant Effect
WP_DEBUG Turns on WordPress debug mode.
WP_DEBUG_LOG Writes errors to wp-content/debug.log when debugging is enabled.
WP_DEBUG_DISPLAY Controls whether notices and warnings are rendered in page output.
SCRIPT_DEBUG Loads non-minified core JavaScript and CSS for development.

A reliable debugging workflow

  1. Back up the site and reproduce the problem on a local or staging copy whenever possible.
  2. Enable WP_DEBUG and WP_DEBUG_LOG, while keeping WP_DEBUG_DISPLAY false.
  3. Reproduce the failing request, then inspect wp-content/debug.log.
  4. Use the timestamp, file path, function name, plugin or theme name, and stack information to identify the first relevant error.
  5. Disable or update the offending extension, correct the code, or restore a known-good version.
  6. After testing, restore production settings so debug output is not exposed and unnecessary logging does not continue.

Displaying errors on a public site can reveal filesystem paths, database details, plugin names, or other information useful to an attacker. A production site can log a fault while returning a normal page to visitors.

Memory limits: WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT

These constants request different amounts of PHP memory for different workloads. WP_MEMORY_LIMIT applies to front-end requests. WP_MAX_MEMORY_LIMIT is the higher limit used for administration and intensive operations such as updates, imports, and image processing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Constant or scope Documented value When it applies
Single-site WP_MEMORY_LIMIT 40M Front-end requests on a single-site installation, under current WordPress Hosting Handbook guidance.
Multisite WP_MEMORY_LIMIT 64M Front-end requests on multisite, under the same guidance.
WP_MAX_MEMORY_LIMIT 256M Administration and intensive tasks when PHP permits a runtime change and the existing limit is not already higher or unlimited.

To request larger values, add:

define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' );

The word “request” matters. These constants cannot defeat a host-level php.ini memory_limit, a managed platform policy, or a server that blocks ini_set(). If PHP refuses runtime changes, the server’s effective ceiling remains in force. A fatal error can therefore continue even after the constants have been increased.

Why more memory may not fix a fatal error

A memory exhaustion message can be a symptom rather than the root cause. A plugin may create an unbounded query, a theme may recurse, an import may contain malformed data, or an image operation may require more resources than the server can provide. Raising the limit can hide the symptom temporarily while leaving the defect in place.

  • Check the PHP error log and wp-content/debug.log for the file and operation that exhausted memory.
  • Test with recently added or updated plugins and the active theme disabled on staging.
  • Break large imports into smaller batches and resize unusually large images.
  • Ask the host what memory_limit is actually active and whether runtime changes are permitted.
  • Increase a limit only when the workload is understood and the server has sufficient physical memory.

What WP_CACHE actually does

WP_CACHE is a bootstrap signal, not a complete caching system. When it is true, WordPress attempts to load wp-content/advanced-cache.php early in the request. Defining the constant by itself does not install a cache, create that drop-in, or configure expiration and purge rules.

If advanced-cache.php is absent, WP_CACHE generally has little or no effect. A page-cache plugin or hosting platform normally creates and manages the drop-in. Removing a caching plugin can leave the file behind, so check the wp-content directory when behavior persists after an uninstall.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Page cache versus object cache

Layer Drop-in Purpose
Page-cache bootstrap advanced-cache.php Serves or prepares cached page responses early in WordPress loading.
Persistent object cache object-cache.php Stores database query results and other objects in a persistent backend.

Persistent object caching through object-cache.php is separate from WP_CACHE and may work without it. Redis- or Memcached-based integrations therefore have different installation files and controls from full-page caching. Do not assume that seeing WP_CACHE means every caching layer is active.

Authentication keys and salts

The standard configuration includes authentication keys and salts. They strengthen cookies and other authentication data by ensuring that captured or forged values are difficult to reuse. Treat them like passwords: keep them private, do not commit them to a public repository, and do not paste them into support forums.

If compromise is suspected, rotating the values invalidates existing login cookies, which logs users out and forces fresh authentication. WP-CLI provides the documented command:

wp config shuffle-salts

Run it from the WordPress installation directory with appropriate filesystem permissions, then verify that administrators can sign in again. Database credentials in the same file deserve the same secrecy and should be changed through the host or database administrator when exposed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Other constants and paths worth knowing

WP_CONTENT_DIR

WP_CONTENT_DIR defines the absolute filesystem path to the wp-content directory. It is a server path, not a browser URL. A wrong value can make WordPress report missing plugins, themes, uploads, or language files even when those files exist elsewhere.

SCRIPT_DEBUG

SCRIPT_DEBUG is useful when a minified core asset obscures a JavaScript or CSS problem. Non-minified files are easier to inspect, but they are not a performance setting for production. Enable it while diagnosing, then return to normal production values.

Database constants and $table_prefix

The database constants tell WordPress how to connect to MySQL-compatible storage. The $table_prefix value determines the prefix used for tables such as wp_options and wp_posts. If the prefix is changed without renaming tables or updating the configuration consistently, WordPress may appear to have no content because it is looking at a different table set.

Production-safe configuration checklist

  • Keep database credentials, salts, and keys outside public repositories and backups shared with untrusted parties.
  • Define custom constants before the editing marker.
  • Use WP_HOME and WP_SITEURL only when their exact runtime values are known.
  • On public production pages, keep WP_DEBUG_DISPLAY disabled.
  • Use WP_DEBUG_LOG selectively and remove or rotate logs that contain sensitive data.
  • Confirm the host’s effective PHP memory_limit before assuming a WordPress memory constant took effect.
  • Inspect both advanced-cache.php and object-cache.php when diagnosing caching behavior.
  • Rotate salts after suspected exposure and expect all users to be logged out.
  • Back up wp-config.php securely before editing it.

Common questions

Can I edit these settings in the dashboard?

Not when the corresponding constant is defined. WordPress shows the configured URL but locks that field because the value comes from wp-config.php.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Does WP_CACHE install caching?

No. It only tells WordPress to try loading wp-content/advanced-cache.php; a cache system must provide and configure that drop-in.

Why does the memory increase have no effect?

The host may block runtime changes or enforce a lower server-level PHP limit. The underlying plugin, theme, import, or image-processing fault may also be consuming excessive memory.

Should debugging be enabled on a live site?

Use debugging on local or staging copies whenever possible. If production diagnosis is unavoidable, log errors while keeping display disabled, reproduce the fault briefly, inspect the log, and restore normal settings.

The Bottom Line

wp-config.php is the control point WordPress reads before startup. Define constants above the editing marker, distinguish public URLs from application URLs, separate logged errors from displayed errors, treat memory values as requests rather than guarantees, and remember that WP_CACHE needs a drop-in. Protect the file’s credentials and salts as carefully as any other production secret.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.