How to Move a WordPress Site from a Subdirectory to the Domain Root
During site development or migration, WordPress is frequently installed into a subdirectory (such as /wp/, /v2/, or /wordpress/). This makes your website accessible only via yourdomain.co.uk/wp/ instead of yourdomain.co.uk.
Moving WordPress to your domain root (public_html or httpdocs) makes your site load directly on your primary domain. While changing the web address seems simple, this process requires moving server files and updating configuration settings, meaning it cannot be done through the WordPress admin panel alone.
Prerequisites & Preparation
Before making any changes to site files or database URLs:
- Take a Complete Backup: Perform a full backup of both your website files and database.
- Note Current Settings: Log into your WordPress dashboard and navigate to Settings > General to take note of your current WordPress Address (URL) and Site Address (URL).
- Check Your Document Root: Identify where your main site lives (
public_htmlon cPanel orhttpdocson Plesk).
Step 1: Update WordPress URL Settings
Before moving any files on the server, you must inform WordPress of its new location. You can do this via the WordPress Admin dashboard or directly in the database.
Option A: Via WordPress Admin Panel (Recommended)
- Log into your WordPress dashboard (e.g.,
yourdomain.co.uk/wp/wp-admin). - Go to Settings > General.
- Change both the WordPress Address (URL) and Site Address (URL) from
(http://yourdomain.co.uk/wp)to(http://yourdomain.co.uk). - Click Save Changes. (Note: Your site will temporarily show errors or break until you complete the file movement steps below).
Option B: Via phpMyAdmin (If Admin Access is Lost)
If you cannot log into the WordPress admin panel:
- Log into cPanel/Plesk and open phpMyAdmin.
- Select your WordPress database from the left menu.
- Open the
wp_optionstable. - Locate the
siteurlandhomerows. - Edit both values, replacing
(http://yourdomain.co.uk/wp)with(http://yourdomain.co.uk).
Step 2: Move Files to the Document Root
- Open File Manager in your hosting control panel (or connect via FTP/SFTP).
- Navigate to your subdirectory (e.g.,
public_html/wp/). - Select all files and folders inside the subdirectory.
- Move them up one level into your domain root directory (
public_htmlorhttpdocs). - Verify that core files like
index.php,wp-config.php, and thewp-contentfolder now reside directly inside the main root folder.
Step 3: Update or Create the .htaccess File
Once the files are moved, the rewrite rules in your .htaccess file must be updated so WordPress handles URLs correctly.
- In your root directory (
public_html), edit the.htaccessfile (enable Show Hidden Files in File Manager if needed). - Update the default WordPress rules to remove the subdirectory path:
Apache
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
- Click Save Changes.
Step 4: Post-Migration Checks & Troubleshooting
Once files and settings are updated, run through these essential checks:
- Flush Permalinks: Log into your updated WordPress dashboard at
yourdomain.co.uk/wp-admin, go to Settings > Permalinks, and click Save Changes without making alterations. This clears old path caches. - Fix Hardcoded Inner Links & Media: Moving files does not automatically update images or internal links previously saved into page content. Use a search-and-replace plugin (such as Better Search Replace) to update references from
yourdomain.co.uk/wp/wp-content/uploads/toyourdomain.co.uk/wp-content/uploads/. - Clear Caches: Flush any caching plugins (LiteSpeed, WP Rocket) and your local browser cache.
Common Pitfalls & When to Contact Support
- 500 Internal Server Error: Usually caused by leftover subdirectory paths in the
.htaccessfile. Re-check your.htaccessrules in Step 3. - 404 Errors on Subpages: Re-saving permalink settings (Step 4) resolves most broken internal link issues.
- Mixed Content Warnings: Occur if some media uploads are hardcoded to
http://or retain old path prefixes.
Need Assistance? If you are uncomfortable moving server files, managing database entries in phpMyAdmin, or run into persistent site errors after moving files, please open a support ticket with our team. We can assist or perform the migration safely on your behalf!