You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Why the Database Still Matters](#why-the-database-still-matters)
18
+
-[Practical Rules](#practical-rules)
19
+
20
+
## The Issue
4
21
5
22
Local WordPress site redirects to production domain after login. This happens if `home` and `siteurl` in the database are overwritten with the production URL.
6
23
7
-
## Quick Fix (Immediate Access)
24
+
###Quick Fix (Immediate Access)
8
25
9
26
Navigate to the config file at `app/public/wp-config.php`
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.
19
36
20
-
## Database Fix
37
+
###Database Fix
21
38
22
-
### Option A: Adminer / phpMyAdmin
39
+
####Option A: Adminer / phpMyAdmin / AdminNeo
23
40
24
41
1. Open your database
25
42
2. Open `wp_options`
@@ -33,15 +50,83 @@ For example:
33
50
http://localhost:10123
34
51
```
35
52
36
-
### Option B: WP-CLI
53
+
####Option B: WP-CLI
37
54
38
55
```bash
39
56
wp option update home 'http://localhost:10123'
40
57
wp option update siteurl 'http://localhost:10123'
41
58
```
42
59
43
-
## Cleanup
60
+
###Cleanup
44
61
45
62
- Remove `WP_HOME` / `WP_SITEURL` from `wp-config.php`
46
63
- Clear browser cache
47
64
- 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
0 commit comments