◦ Comprehensive security
◦ 24/7 support
WordPress Guide → Development → Moving Subfolder To Root Directory
How to move your WordPress from a subfolder to the root directory
Starting your WordPress site in a subfolder is a smart way to test or build quietly. But when you’re ready to go live, you’ll want it to show up at your main domain—without the subfolder.
Let’s walk through how to move your WordPress installation from a subfolder to the root directory, safely and step by step.
Get fast, reliable hosting for WordPress
Power your site with the industry’s fastest, most optimized WordPress hosting
Overview: how to move WordPress from a subfolder to the root
To move WordPress from a subfolder to the root directory, follow these steps:
- Back up your site.
- Use your host’s file manager or FTP to move files from the subfolder to the root.
- Update the WordPress Address (URL) and Site Address (URL) in Settings > General.
- Edit wp-config.php if needed to reflect the new location.
- Update the site URL in the database using phpMyAdmin.
- Regenerate permalinks and test your site.
Each step is crucial for keeping your site functional and error-free.
Why move WordPress from a subfolder to root?
Here’s why you might want to move your site:
- You installed WordPress in a subfolder like /wordpress for testing.
- You’re now ready to make the site live on your main domain, like yourdomain.com.
- Keeping the subfolder in the URL makes your site harder to remember, less professional, and less SEO-friendly.
- You want to clean up your site structure and simplify management.
Whatever your reason, making this move the right way keeps your site safe and smooth.
Step 1: back up your WordPress site
Always start with a full backup. Mistakes can happen, and this gives you a safety net.
You’ll want to back up two things:
- Your WordPress files, which include your theme, plugins, uploads, and configuration files.
- Your WordPress database, which stores your posts, pages, settings, and user data.
Easiest backup method (plugin)
Use a free plugin like UpdraftPlus or All-in-One WP Migration to back up both files and the database. These plugins also let you download backups to your computer or cloud storage.
Manual backup method
- Use your hosting control panel (like cPanel) to open File Manager.
- Compress and download your entire WordPress subfolder.
- Open phpMyAdmin, export the entire database as an SQL file.
Once you’ve saved both the files and the database, you’re ready to move on.
Step 2: move WordPress files to the root directory
Now you need to move your WordPress files from the subfolder (e.g., /wordpress) to the root directory (e.g., /public_html).
There are two common ways to do this: File Manager or FTP.
Option 1: Using File Manager (cPanel or hosting dashboard)
- Log in to your hosting account and go to File Manager.
- Navigate to the subfolder where WordPress is installed (like /public_html/wordpress).
- Select all the files and folders inside—not the folder itself.
- Click Move or Copy, and choose /public_html as the destination.
Option 2: Using FTP (File Transfer Protocol)
- Open an FTP client like FileZilla.
- Connect to your site using your FTP login info (usually found in your hosting dashboard).
- Navigate to the subfolder and select all files.
- Drag and drop them into the root folder (/public_html or /www).
Tip: Do not delete anything from the subfolder yet. You’ll test the site first to make sure the move worked correctly.
Step 3: update the WordPress site URL
Once your files are in place, you need to update the site’s URL settings so WordPress knows it lives at the root now.
Method A: Update via WordPress dashboard
If you can still access your dashboard:
- Go to yourdomain.com/your-subfolder/wp-admin.
- Navigate to Settings > General.
- Find the WordPress Address (URL) and Site Address (URL) fields.
- Change both to: https://yourdomain.com
- Click Save Changes.
This might log you out or break the admin panel temporarily—that’s normal after a move. Just proceed with the next steps.
Step 4: edit wp-config.php (if you can’t access the dashboard)
If your dashboard is unavailable after the move, you can hardcode the new URLs directly.
- In your root directory, locate and open the wp-config.php file.
- Add these two lines just above the “That’s all, stop editing!” comment:
define(‘WP_HOME’, ‘https://yourdomain.com’);
define(‘WP_SITEURL’, ‘https://yourdomain.com’); - Save and close the file.
This forces WordPress to use the new root URL, bypassing the settings page.
Step 5: update the database (site URL and internal links)
Even after changing the site address, the database might still include old subfolder references—especially in links and media files.
Update siteurl and home in the database
- Open phpMyAdmin from your hosting dashboard.
- Select your WordPress database from the left sidebar.
- Click on the table named wp_options (or yourprefix_options).
- Find the rows labeled siteurl and home.
- Edit them to remove the subfolder from the URL (e.g., https://yourdomain.com).
Update old URLs across content
To fix media links, menu items, and other internal references:
- Install and run Better Search Replace.
- Search for: /your-subfolder
- Replace with: nothing (just leave the replace field empty).
- Run it as a dry run first to see what it will change, then apply changes.
This step ensures your entire site now points to the correct root URLs.
Step 6: regenerate permalinks and fix .htaccess
You’ll want to make sure your permalinks and redirects are refreshed to reflect the new structure.
Regenerate permalinks
- Go to your new dashboard URL: yourdomain.com/wp-admin.
- Navigate to Settings > Permalinks.
- Click Save Changes (no need to change any setting).
This triggers WordPress to rebuild your .htaccess file and fix link routing.
Check .htaccess manually
If you had custom rules or if permalinks aren’t working:
- Open .htaccess in the root directory.
- Make sure it contains this default WordPress code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress - Save the file and refresh your site.
Optional: remove the old subfolder
Once your site is fully functional from the root directory:
- Revisit all major pages, menus, and images to confirm everything works.
- When you’re confident nothing is missing, go back into File Manager or FTP.
- Delete the old subfolder (/wordpress or whatever it was named).
This step is optional, but it helps clean up your site’s file structure and avoid confusion later.
Common issues after moving WordPress
1. Broken links or missing media
This usually means some internal links still point to the old subfolder. Re-run the Better Search Replace plugin and clear your browser cache.
2. Styles and scripts not loading
Often caused by:
- Incorrect URL settings in wp-config.php.
- Cached CSS/JS in your browser or CDN.
Clear your cache and double-check your site URL settings.
3. 404 errors on pages
If clicking on posts or pages gives you a “Page Not Found” error:
- Revisit Settings > Permalinks and click Save Changes again.
- Confirm that .htaccess exists and contains the right rules.
4. Login redirects to old subfolder
This can happen if you missed updating the database or hardcoded settings. Make sure both the wp-config.php and wp_options table reflect the root URL.
Alternatives to manual migration
Use a plugin (easiest for beginners)
Plugins can automate many of these steps:
- Duplicator: Packages your site and lets you reinstall it anywhere.
- All-in-One WP Migration: Makes moving the site between directories or servers very easy.
- WP Staging: Best if you’re moving from a staging site to a live one.
Make sure to follow plugin instructions closely and always test after migration.
Hire a professional
If your site is large, complex, or business-critical, consider a professional migration service. They’ll handle file movement, database cleanup, and testing, which can save time and avoid downtime.
Next steps for moving WordPress from a subfolder to the root
Moving WordPress from a subfolder to the root directory gives your site a clean, user-friendly URL and eliminates development clutter.
Once you’ve completed the move, test your site thoroughly to ensure every page, link, and media file works as expected.
Ready to upgrade your WordPress experience? Professional hosting improves speeds, security, and reliability for a website and a brand that people find engaging and trustworthy.
Don’t want to deal with server management and maintenance? Our fully managed hosting for WordPress is the best in the industry. Our team are not only server IT experts, but WordPress hosting experts as well. Your server couldn’t be in better hands.
Click through below to explore all of our hosting for WordPress options, or chat with a WordPress expert right now to get answers and advice.
Additional resources
What is managed WordPress hosting? →
Get details and decide if managed WordPress hosting is right for you.
WordPress development agency guide: What they do, when to hire one, and how to choose →
Discover what WordPress development agencies do, when to hire one, and how to choose the right partner for your website project.
A complete guide to WordPress shortcodes →
Shortcodes make life easier. Learn how to get started!