How to move WordPress out of a subdirectory
Use the WordPress Address and Site Address split to serve from the root without moving files, or move the files properly if you would rather.
This situation is common enough to have a name: WordPress was installed into a folder — often /wordpress, or a folder created automatically by a one-click installer — and now the site needs to be reachable at the plain domain instead of yourdomain.com/wordpress. There are two ways to fix it: WordPress has a built-in feature that does this without moving a single file, and there is the manual approach of physically relocating everything. The built-in method is almost always the better choice.
Method 1: the WordPress Address and Site Address split
WordPress deliberately separates two settings that most sites keep identical, and that separation exists specifically for this situation:
| Setting | Means |
|---|---|
| WordPress Address (siteurl) | Where the actual WordPress files live |
| Site Address (home) | What visitors type to reach the site |
Setting these to two different values tells WordPress "keep the files exactly where they are, but behave as though the site is served from this other address." No files move at all.
-
Back up the site first
Files and database together. See backing up a WordPress site.
-
Copy index.php out of the subdirectory into the domain root
This is the one file that has to move. Open it and find the line loading
wp-blog-header.php, then update the path so it points back into the subdirectory where the rest of WordPress still lives.require __DIR__ . '/wordpress/wp-blog-header.php'; -
Go to Settings, then General
Leave WordPress Address as the subdirectory path —
https://yourdomain.com/wordpress— and change Site Address to the plain domain —https://yourdomain.com. -
Save, then test
Load the plain domain and confirm the site appears there correctly, including the admin area and permalinks.
The copied index.php at the root is a small loader that pulls in WordPress from its actual location in the subdirectory. Visitors hitting the root domain load this file, which quietly loads the rest of WordPress from where it really lives, while WordPress itself has been told to generate every link using the plain domain rather than the subdirectory path.
Method 2: physically move the files
The more thorough option, if you would rather not have WordPress core files living in a subdirectory at all going forward — useful before handing a site to someone else, since a plain root install is less confusing to work with later.
-
Back up files and database
This method involves more moving parts than Method 1, so a solid backup matters even more here.
-
Move every file out of the subdirectory into the domain root
Over FTP or the file manager, move the entire contents of the subdirectory — not the folder itself — up one level.
-
Update siteurl and home in the database
Both should now be the plain domain. Set this either through Settings, General in the dashboard, or directly in the
wp_optionstable via phpMyAdmin if the site will not load correctly with files newly relocated. -
Run a search-and-replace across the database
Anything referencing the old subdirectory path in post content, image URLs, or serialized settings needs updating to the new plain-domain path. See searching and replacing inside a database for how to do this without corrupting serialized data.
-
Delete the old, now-empty subdirectory
Once you have confirmed everything works from the new location.
Because Method 1 leaves the files exactly where they were, any hardcoded reference to the old path inside content still works correctly, since that path is still real. Method 2 genuinely relocates the files, so anything still pointing at the old path breaks unless you find and update it.
Which method to choose
- Method 1 if you want the fastest, lowest-risk fix, and do not mind that WordPress core files technically still live in a subdirectory behind the scenes — which is invisible to every visitor.
- Method 2 if you specifically want a clean file structure with no subdirectory involved, and are prepared to do the extra search-and-replace work properly.
After either method: fix permalinks
Go to Settings, then Permalinks, and save once without changing anything. This forces WordPress to regenerate its rewrite rules and the corresponding .htaccess file to match the new address, which avoids individual pages returning a 404 error even though the homepage loads correctly. If posts still 404 after this, see fixing WordPress permalinks returning 404.
Checking everything actually moved
- Load the homepage at the plain domain and confirm it works with no redirect back to the old subdirectory address.
- Click through to an inner page and check the URL is correct.
- Log into wp-admin and confirm the dashboard loads normally.
- Check image URLs on an older post to confirm they were not left pointing at the subdirectory path.
Related reading
Three ways to change the WordPress site URL, and why a search-and-replace on the database is usually still required afterwards.
How to use .htaccess on your hosting accountOne file that controls redirects, rewrites and access rules for a whole folder — and one typo in it that can take the site offline.
How to back up a WordPress siteFiles and database, together — a backup missing either one is not a backup. Three ways to take one, and how to prove it works.
How to fix WordPress permalinks returning 404The home page loads, but every post and page 404s. Almost always a permalinks or .htaccess problem, and almost always fixable in minutes.