Have a Question?

If you have any question you can ask below or enter what you are looking for!

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_html on cPanel or httpdocs on 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.

  1. Log into your WordPress dashboard (e.g., yourdomain.co.uk/wp/wp-admin).
  2. Go to Settings > General.
  3. Change both the WordPress Address (URL) and Site Address (URL) from (http://yourdomain.co.uk/wp) to (http://yourdomain.co.uk).
  4. 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:

  1. Log into cPanel/Plesk and open phpMyAdmin.
  2. Select your WordPress database from the left menu.
  3. Open the wp_options table.
  4. Locate the siteurl and home rows.
  5. Edit both values, replacing (http://yourdomain.co.uk/wp) with (http://yourdomain.co.uk).

Step 2: Move Files to the Document Root

  1. Open File Manager in your hosting control panel (or connect via FTP/SFTP).
  2. Navigate to your subdirectory (e.g., public_html/wp/).
  3. Select all files and folders inside the subdirectory.
  4. Move them up one level into your domain root directory (public_html or httpdocs).
  5. Verify that core files like index.php, wp-config.php, and the wp-content folder 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.

  1. In your root directory (public_html), edit the .htaccess file (enable Show Hidden Files in File Manager if needed).
  2. 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
  1. 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/ to yourdomain.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 .htaccess file. Re-check your .htaccess rules 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!