If you built or tested your WordPress site in a subfolder (for example yourdomain.com/new) and now want it to run from your domain's root, you need to move three separate things: the files, the website address stored in the database, and any links inside your content that point to the old path. Skipping any one of these usually leaves you with broken images, dead links, or a redirect loop.
Take a full backup of your website files and database before you begin. This process is safe to reverse, but only if you have something to restore from if a step goes wrong.
Step 1: Move the WordPress Files to the Root Folder
Your WordPress files currently sit inside a subfolder within public_html. You need to move everything out of that subfolder and into public_html itself.
In cPanel
- Log in to cPanel and open File Manager.
- Navigate into public_html and open the subfolder your site is installed in.
- Click Select All to select every file and folder inside it, including hidden files such as .htaccess, then click Copy or Cut.
- Paste everything directly into public_html.
- Once you've confirmed the site still loads its content correctly, delete the now-empty subfolder.
In DirectAdmin
- Log in to DirectAdmin and open File Manager.
- Go to domains/yourdomain.com/public_html and open the subfolder.
- Select every file and folder inside it, including hidden ones, and choose Move.
- Set the destination to the public_html folder one level up, then confirm.
- Delete the empty subfolder once you've checked the move worked.
Step 2: Update the Site Address in Your Database
WordPress stores its site address in the database, not just in the files, so moving the files alone will not fix the URL. Open phpMyAdmin from your control panel, select your WordPress database, and open the wp_options table (your table prefix may differ, for example wp7x_options).
Find the siteurl and home rows and edit each value, removing the subfolder from the end (for example changing https://yourdomain.com/new to https://yourdomain.com).
If you can't log in to wp-admin to check this, you can temporarily add two lines to wp-config.php above the line that says That's all, stop editing!:define('WP_SITEURL', 'https://yourdomain.com');anddefine('WP_HOME', 'https://yourdomain.com');. Remove them once the database values are confirmed correct.
Step 3: Update Links Inside Your Posts and Pages
Any image or internal link you added manually while the site lived in the subfolder still points to the old path. The fastest way to fix this across the whole site is a search-and-replace in the database.
- In phpMyAdmin, use the Search tab (or the SQL tab) on the wp_posts and wp_postmeta tables to find the old path, such as /new/wp-content, and replace it with the correct new path.
- If your WordPress installation already has a search-and-replace plugin available, you can use it instead; point it at the same old and new values.
Step 4: Check Your .htaccess File
Make sure public_html has a standard WordPress .htaccess file that doesn't still reference the old subfolder in a RewriteBase line. If you're not sure, go to Settings, then Permalinks in wp-admin and click Save Changes without altering anything. WordPress will regenerate the file automatically.
Step 5: Clear Caches and Test
- Clear any caching plugin's cache, and your hosting account's server-level cache if you have one enabled.
- Clear your browser cache, or test in a private browsing window.
- Check your homepage, a few inner pages, and your login at yourdomain.com/wp-admin.
If pages start returning a 404 error after the move, the fix is almost always the permalinks setting. See How to Fix WordPress Posts and Pages Returning a 404 Error for the steps.