Skip to content

Commit be56c0d

Browse files
committed
docs: add WP Boot Order overview
1 parent 2529feb commit be56c0d

1 file changed

Lines changed: 91 additions & 6 deletions

File tree

WordPress/WP-Core/wp-localhost-redirect-fix.md

Lines changed: 91 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
# WordPress Localhost URL Redirect Fix
22

3-
**Problem**
3+
Updated: 21 JAN 2026
4+
5+
- [WordPress Localhost URL Redirect Fix](#wordpress-localhost-url-redirect-fix)
6+
- [The Issue](#the-issue)
7+
- [Quick Fix (Immediate Access)](#quick-fix-immediate-access)
8+
- [Database Fix](#database-fix)
9+
- [Option A: Adminer / phpMyAdmin / AdminNeo](#option-a-adminer--phpmyadmin--adminneo)
10+
- [Option B: WP-CLI](#option-b-wp-cli)
11+
- [Cleanup](#cleanup)
12+
- [WordPress Boot Order \& URL Resolution Overview](#wordpress-boot-order--url-resolution-overview)
13+
- [Boot Order for WordPress Simplified](#boot-order-for-wordpress-simplified)
14+
- [URLs in WordPress](#urls-in-wordpress)
15+
- [How `wp-config.php` Overrides the Database](#how-wp-configphp-overrides-the-database)
16+
- [Authority Hierarchy (Highest → Lowest)](#authority-hierarchy-highest--lowest)
17+
- [Why the Database Still Matters](#why-the-database-still-matters)
18+
- [Practical Rules](#practical-rules)
19+
20+
## The Issue
421

522
Local WordPress site redirects to production domain after login. This happens if `home` and `siteurl` in the database are overwritten with the production URL.
623

7-
## Quick Fix (Immediate Access)
24+
### Quick Fix (Immediate Access)
825

926
Navigate to the config file at `app/public/wp-config.php`
1027

@@ -17,9 +34,9 @@ define('WP_SITEURL', 'http://localhost:10123');
1734

1835
This stops redirects instantly and allows you to log in. Afterwards, you will need to fix the database manually or use a plugin (like Better Search & Replace) to swap your production URL with your localhost URL.
1936

20-
## Database Fix
37+
### Database Fix
2138

22-
### Option A: Adminer / phpMyAdmin
39+
#### Option A: Adminer / phpMyAdmin / AdminNeo
2340

2441
1. Open your database
2542
2. Open `wp_options`
@@ -33,15 +50,83 @@ For example:
3350
http://localhost:10123
3451
```
3552

36-
### Option B: WP-CLI
53+
#### Option B: WP-CLI
3754

3855
```bash
3956
wp option update home 'http://localhost:10123'
4057
wp option update siteurl 'http://localhost:10123'
4158
```
4259

43-
## Cleanup
60+
### Cleanup
4461

4562
- Remove `WP_HOME` / `WP_SITEURL` from `wp-config.php`
4663
- Clear browser cache
4764
- Restart Local site
65+
66+
<br>
67+
68+
## WordPress Boot Order & URL Resolution Overview
69+
70+
### Boot Order for WordPress Simplified
71+
72+
1. `index.php`
73+
2. `wp-config.php`
74+
3. Database connection
75+
4. Load `wp_options`
76+
5. Resolve site URLs
77+
6. Route request / apply redirects
78+
79+
**Note:** `wp-config.php` is loaded **before** WordPress reads the database.
80+
81+
### URLs in WordPress
82+
83+
By default, WordPress uses stored options:
84+
85+
- `home``wp_options.home`
86+
- `siteurl``wp_options.siteurl`
87+
88+
These values control:
89+
90+
- Canonical URLs
91+
- Login redirects
92+
- Admin routing
93+
- Asset URLs
94+
95+
### How `wp-config.php` Overrides the Database
96+
97+
The `wp-config.php` file can short circuit the process of loading from the database. When you define:
98+
99+
```php
100+
define('WP_HOME', 'http://localhost:10123');
101+
define('WP_SITEURL', 'http://localhost:10123');
102+
```
103+
104+
WordPress:
105+
106+
- Sees these constants already defined in the configuration file
107+
- Skips reading `home` / `siteurl` from the database
108+
- Uses the constants for the entire request
109+
110+
**No database writes occur.** This is a runtime override only.
111+
112+
### Authority Hierarchy (Highest → Lowest)
113+
114+
1. Constants in `wp-config.php`
115+
2. Filters (advanced usage)
116+
3. Database (`wp_options`)
117+
4. Inferred values
118+
119+
Higher levels always override lower ones.
120+
121+
### Why the Database Still Matters
122+
123+
- `wp-config.php` does **not** sync or update options
124+
- Bad values remain stored until fixed
125+
- Removing overrides re-exposes DB issues
126+
127+
### Practical Rules
128+
129+
- `wp-config.php` = execution-time truth
130+
- Use config overrides to regain access
131+
- Database = stored truth
132+
- Fix the database for permanent correctness

0 commit comments

Comments
 (0)