How To Move WordPress From A Subfolder To The Root Directory: A Step-By-Step Guide

Moving your WordPress site from a subfolder to the root directory might sound tricky, but it’s easier than you think. Whether you’re optimizing your website for better visibility or simplifying your URL structure, this process can make a big difference. By following a few straightforward steps, you’ll have your site running smoothly in its new location without breaking links or losing data.

Why Move WordPress From A Subfolder To The Root Directory

Relocating WordPress from a subfolder to the root directory enhances site accessibility and professional appeal. It optimizes your website’s structure, making URLs simpler and easier for users and search engines to navigate. For example, changing from yourdomain.com/subfolder to yourdomain.com eliminates directory references and contributes to a cleaner digital presence.

A root directory location improves SEO performance by increasing the likelihood of ranking higher in search engine results. Search engines often regard URLs that originate from the root directory as more relevant, which could boost traffic and visibility.

Moving to the root directory can enhance user trust and brand credibility. Visitors may perceive your website as professional and reliable when it lacks excess directory paths in the URL. For instance, a URL like yourdomain.com/about often appears more authoritative than yourdomain.com/subfolder/about.

This migration also simplifies website management. With fewer subfolder dependencies, maintaining your WordPress site becomes more manageable.

Preparing For The Move

Preparing your WordPress site before moving from a subfolder to the root directory is essential to avoid data loss or functionality issues. Proper preparation ensures a seamless transition, maintaining your site’s structure and SEO value.

Backup Your WordPress Site

Create a full backup of your WordPress site to secure your files and database in case of unforeseen errors. Use reliable plugins like UpdraftPlus or BackupBuddy to automate the process. Manually back up your files via FTP by downloading the wp-content folder and other critical files, including the .htaccess file. Export the database through phpMyAdmin or similar tools, ensuring all tables are saved. Store your backups locally or in a cloud service for easy access.

Check The Current Site Configuration

Examine your site’s current setup to identify dependencies or custom configurations. Confirm that the site URL reflects the subfolder location by navigating to Settings > General in your WordPress dashboard. Record the values for WordPress Address (URL) and Site Address (URL). Review the .htaccess file for custom rewrite rules that might impact the move. Check permalinks and any plugins dependent on the subfolder to avoid broken links. Document these configurations to facilitate updates after the move.

Moving WordPress Files To The Root Directory

Relocating files from a subfolder to the root directory ensures proper site functionality and eliminates unnecessary subfolder dependencies. Follow the steps below for a seamless transfer.

Accessing The Website Files

Access your WordPress files using File Manager in your hosting control panel or an FTP client like FileZilla. Log in with your credentials provided by the hosting provider. Locate the subfolder containing your WordPress files in the root directory, typically named /public_html/subfolder or similar.

Verify that all WordPress core files, plugins, themes, and the wp-config.php file are present. This ensures you won’t miss any critical data during the transfer.

Transferring Files To The Root Directory

Transfer the files by copying everything from the subfolder to the root directory (/public_html). Use the following steps:

  1. Copy Files: Select all files in the subfolder and choose “Copy” or “Move” within the File Manager. If using FTP, download the files locally before re-uploading them to the root directory.
  2. Preserve Hidden Files: Ensure you include hidden files, like .htaccess, in the transfer. In File Manager, enable “Show Hidden Files” from the settings menu.
  3. Verify File Placement: Confirm that files like index.php, wp-config.php, and the wp-content folder are directly within the root directory without nesting in another folder.
  4. Delete Subfolder Contents (Optional): Once you’ve verified the transfer, you can delete the original subfolder to avoid confusion later.

Always double-check that every file has been moved correctly to prevent errors when accessing the website.

Updating WordPress URLs

After relocating WordPress files from a subfolder to the root directory, updating WordPress URLs ensures your site functions correctly and links point to the new location. These updates prevent errors like broken links or misdirected traffic.

Adjust Site URL And Home URL

Update the WordPress Site URL and Home URL to reflect the root directory location. Access your WordPress admin dashboard by navigating to <yourdomain.com/subfolder>/wp-admin before updating.

  1. Navigate to General Settings: In the WordPress dashboard, go to Settings > General.
  2. Modify URLs: Update the “WordPress Address (URL)” and “Site Address (URL)” fields to your root domain, e.g., https://yourdomain.com.
  3. Save Changes: Click the Save Changes button to apply the updates.

If the admin dashboard is inaccessible, edit these settings through the wp-config.php file:

  • Add the following lines at the bottom of the file, replacing https://yourdomain.com with your root URL:

define('WP_HOME', 'https://yourdomain.com');

define('WP_SITEURL', 'https://yourdomain.com');

Test the updated URLs by attempting to access the homepage and an internal page.

Refresh your permalink structure to ensure all links work correctly with the root directory path.

  1. Access Permalink Settings: Go to Settings > Permalinks in the WordPress dashboard.
  2. Select The Desired Structure: Choose your preferred permalink format, such as “Post Name,” for SEO-friendly URLs.
  3. Save Permalinks: Click the Save Changes button to regenerate the .htaccess file and fix internal link paths.

For custom permalink issues, verify that hidden files like .htaccess were properly moved, and check server permissions to ensure updates take effect.

Checking The Website After The Move

After moving WordPress from a subfolder to the root directory, you confirm everything works as intended. This minimizes disruptions and ensures full functionality.

Test Website Functionality

Verify the website loads correctly in a web browser. Enter the domain without the subfolder to confirm the homepage displays as expected. Visit a few internal pages to check for proper navigation.

Confirm that all links, images, and media files appear without errors. Look for missing images or broken links, which indicate path issues. Test forms, search bars, and interactive features for proper operation.

Log into your WordPress admin dashboard to ensure access is functional. Verify key settings like themes and plugins are operational without errors.

Fix Potential Issues

Resolve broken links by updating URLs in the database. Tools like Search and Replace or plugins designed for URL updates simplify this process. Replace any outdated subfolder paths with root directory URLs.

Check your .htaccess file for errors or misconfigurations. Ensure redirects or custom rules don’t interfere with site functionality.

Address missing assets by confirming files are present in the root directory. Re-upload missing files or fix incorrect file paths as needed.

Test the website across devices and browsers. Resolve browser-specific issues or caching problems by clearing your site cache and refreshing users’ access points.

Best Practices For A Smooth WordPress Move

Adhering to best practices ensures a seamless and efficient WordPress migration from a subfolder to the root directory. Implement these methods to minimize errors and ensure your site’s functionality remains intact.

Create A Full Backup

Always back up your entire site before making changes. Save both the database and all site files using a reliable plugin like UpdraftPlus or manual methods like exporting from cPanel. A full backup protects against data loss if issues arise during the migration.

Verify File Structure Consistency

Ensure the structure of your WordPress installation in the subfolder matches what will be needed in the root directory. Confirm that core files, themes, custom plugins, and the wp-config.php file are intact. Hidden files, such as .htaccess, must also be included during the transfer.

Test Locally Before Moving

Run the website on a local server replica using tools like XAMPP or Local. This allows you to identify any configuration issues in a controlled environment without affecting the live site.

Update Site URLs

After moving files to the root directory, update the Site URL and Home URL settings under the General Settings tab in the WordPress admin dashboard. If you can’t access the dashboard, edit the wp-config.php file and add these lines:


define('WP_HOME', 'https://example.com');

define('WP_SITEURL', 'https://example.com');

Replace example.com with your domain.

Navigate to Settings > Permalinks in your WordPress admin dashboard and click Save Changes without modifying existing settings. This regenerates the .htaccess file, ensuring links direct to the new root location.

Use a plugin like Broken Link Checker or an online tool to scan your site for broken links. Fix these links promptly by updating URLs or redirection rules in the .htaccess file to maintain user experience and SEO rankings.

Retain A Copy Of The Subfolder

Keep a copy of the original subfolder temporarily. If the migration isn’t successful or files are missing, this backup can restore the previous state. Delete the subfolder only after confirming the site’s functionality in the root.

Test Across Platforms

After completing the move, test your website on various devices and browsers for compatibility. Verify all pages, images, and interactive features, ensuring nothing is misaligned or broken. Address any discrepancies promptly.

Secure Your Root Directory

Enhance root directory security by updating file permissions, disabling directory browsing, and securing critical files like wp-config.php with appropriate rules in the .htaccess file. This prevents unauthorized access.

Following these practices optimizes the migration process, ensuring an error-free transition with minimal downtime.

Conclusion

Moving your WordPress site from a subfolder to the root directory can significantly enhance your website’s functionality, visibility, and professionalism. By taking the time to prepare, follow the outlined steps, and test thoroughly, you ensure a smooth transition with minimal disruptions.

This process not only improves your site’s structure but also boosts its SEO potential and user experience. With proper planning and attention to detail, you can confidently relocate your WordPress site and enjoy the benefits of a more accessible and streamlined online presence.

Frequently Asked Questions

What is the benefit of moving a WordPress site to the root directory?

Moving a WordPress site to the root directory improves website visibility, creates a simplified URL structure, enhances SEO performance, and builds user trust. Search engines often favor root directory URLs, which can lead to better rankings and more traffic.

Should I back up my website before moving it to the root directory?

Yes, creating a full backup of your website is crucial. It ensures you can restore your data if something goes wrong during the transition. Use reliable backup plugins or manual methods to save all files and the database.

How do I move WordPress files from a subfolder to the root directory?

You need to copy all WordPress files (including hidden files) into the root directory using File Manager in your hosting control panel or an FTP client like FileZilla. Verify the file structure after transferring to avoid errors.

Do I need to update WordPress URLs after moving the site?

Yes, updating the Site URL and Home URL is necessary to ensure proper site functioning. This can be done via the WordPress admin dashboard or by editing the wp-config.php file if needed.

Use tools or plugins designed for link management to identify and fix broken links. Additionally, refresh your WordPress permalink structure by accessing Permalink Settings and saving changes.

What should I do if my website isn’t working properly after the move?

Check for missing files, verify the .htaccess file, and ensure updated URLs and settings. If the issue persists, consult your hosting provider’s support or review each step of the migration process for errors.

Can I test my WordPress site locally before moving it to the root directory?

Yes, testing locally provides an opportunity to verify the site’s functionality and file structure. This step minimizes issues during the actual migration to the root directory.

Will my SEO be affected during the move?

If done correctly, your SEO will likely improve after the move. However, ensure proper URL updates and fix any broken links promptly to prevent temporary traffic or ranking issues.

Should I delete the original subfolder after moving my site?

You can delete the original subfolder after confirming the site is working correctly in the root directory. Retaining it temporarily is a good practice in case you need to restore any files.

How can I secure my website after moving it to the root directory?

Enhance root directory security by updating permissions, using secure passwords, and installing plugins to prevent unauthorized access. Regular backups and monitoring can further improve overall security.

Instabuilt
Instabuilt

Crafting Unique Online Experiences with Custom Website Templates

Articles: 79