Get a free website with any plan

See how
WORDPRESS

Moving WordPress from a subdirectory to the root

Last updated

IN SHORT

To run WordPress from your domain root on Flashcloud without moving all core files, change the Site Address (URL) to the root URL in WordPress settings while keeping the WordPress Address pointing to the subdirectory. Then copy index.php to your root directory and update its require path to point back to the subdirectory.

If WordPress is installed in a subdirectory like example.com/blog and you want it running at example.com instead, you don't need to reinstall anything. WordPress has a built-in setting for this: change the Site Address (URL) while leaving the WordPress Address (URL) pointing at the subdirectory, then move your index file up a level. No plugin required for most sites, though one exists if you'd rather not touch files directly.

Before you start

Take a backup first. This is a structural change and if a step goes wrong partway through, you want a clean point to return to. See Backing up your WordPress site for more on backups.

If the site is business-critical or you want to test the move without any live-site risk, do it on a staging copy first. See Using WordPress staging for the workflow.

The built-in method

WordPress separates two settings that people often assume are the same thing:

  • WordPress Address (URL): where your WordPress core files actually live.
  • Site Address (URL): what visitors type to reach your site.

Normally these match. To move to the root without moving every WordPress file, you set them differently on purpose.

  1. Log into wp-admin and go to Settings → General.
  2. Leave WordPress Address (URL) as https://example.com/blog.
  3. Change Site Address (URL) to https://example.com.
  4. Save. The admin area will look broken immediately after this step. That's expected, keep going.

Now move two files out of the subdirectory and into your site's root using File Manager (Services → your hosting → File Manager in the portal, or cPanel's File Manager tool):

  • Copy index.php from /blog/ to the root folder (usually public_html).
  • Open the copied root-level index.php in the editor and find the line:
    require __DIR__ . '/wp-blog-header.php';
    Change it to point back at the subdirectory:
    require __DIR__ . '/blog/wp-blog-header.php';
  • Copy your .htaccess file from /blog/ to the root as well, if you have custom rules in it. A fresh WordPress .htaccess will otherwise regenerate with defaults.

Once both files are in place at the root, load https://example.com/wp-admin. You should be able to log back in normally, and the site should now serve from the root.

Fix permalinks last

Go to Settings → Permalinks and click Save Changes, even without editing anything. This forces WordPress to rewrite the rewrite rules in your root .htaccess against the new URL structure. Skipping this step is the most common reason people see 404s on every page except the homepage after a move like this.

If you'd rather use a plugin

A site-URL-change plugin from the WordPress repository automates the same file moves and search-replaces the site URL throughout the database, which matters if you have internal links, image paths, or serialized data referencing the old subdirectory path. For most brochure sites the built-in method above is enough since the URL itself isn't changing, only which directory serves it. For larger sites with years of hardcoded internal links in post content, a plugin that does a proper search-and-replace pass is worth the extra step.

Clean up old links

If anything external still links to example.com/blog/some-post, that URL will now 404 unless you redirect it. The cleanest fix is a rule in your root .htaccess that sends /blog/* traffic to the equivalent root path, placed above the WordPress block so it runs first.

When to contact support

If permalinks still 404 after saving them, or the admin area won't load after the file swap, open a ticket from Support in the portal. Include the exact URL structure you're moving from and to and the steps you've taken so far.

Common questions

Why does my WordPress admin look broken after changing the site URL?

That is expected right after updating the setting. Access returns to normal once you copy index.php and your .htaccess file into the root folder and update the require path.

Why does every page give a 404 error except the homepage?

Your permalink rewrite rules need to be refreshed. Go to Settings, open Permalinks, and click Save Changes to force WordPress to update the rules in your root .htaccess file.

Do I need a plugin to move WordPress to the root?

No, the built-in settings handle the move for most brochure sites. Consider a plugin if your site has years of hardcoded internal links, image paths, or serialized database entries pointing to the old subdirectory.

How do I stop old subdirectory links from returning 404 errors?

Add a redirect rule to your root .htaccess file. Place the rule above the WordPress block so incoming traffic from the old subdirectory path routes to the equivalent root path.

CAN'T FIND IT?

Real humans answer fast.

Hosting with us? Open a ticket and a real person replies - no scripts, no upsells. Still choosing a host? The same team is included with every plan, from day one.