[Solved] How to Move WordPress URL from /wp to the Main Domain

You are here:
Estimated reading time: 2 min

Topic: How to Move WordPress URL from /wp to the Main Domain

If your WordPress website is currently installed in a subdirectory (e.g., www.example.com/wp) and you want to move it to the main domain (e.g., www.example.com), follow these steps:

  1. Create a Backup:
    Before making any changes, it’s essential to create a full backup of your website, including the database and files. This ensures you can restore your website in case anything goes wrong during the migration process.
  2. Update Site Address:
    Log in to your WordPress dashboard and go to “Settings” > “General.” In the “WordPress Address (URL)” and “Site Address (URL)” fields, replace “/wp” with the main domain (e.g., www.example.com). Click “Save Changes.”
  3. Update Permalinks:
    After changing the site address, visit “Settings” > “Permalinks” and click “Save Changes.” This updates the permalinks structure to reflect the new URL.
  4. Move WordPress Files:
    Using an FTP client or your hosting control panel’s file manager, move all WordPress files and folders from the /wp directory to the root directory (public_html or www). This includes the “wp-admin,” “wp-content,” “wp-includes,” and other files.
  5. Update .htaccess File:
    If you have a custom .htaccess file in the root directory, update the “RewriteBase” to reflect the new location. For example:
   RewriteBase /
  1. Update wp-config.php:
    Open the wp-config.php file located in the root directory. Find the lines that define the database connection settings and update them if needed. The database name, username, and password should remain the same if you are using the same database.
  2. Database Search & Replace:
    To ensure all internal links and references are updated, you need to perform a search and replace in the database. It’s crucial to handle this step with caution, as modifying the database directly can cause irreversible damage if not done correctly. You can use a plugin like “Better Search Replace” to safely perform a search and replace. Install the plugin, go to “Tools” > “Better Search Replace,” and enter the old URL with “/wp” and the new URL without “/wp.” Be sure to select all necessary database tables and perform a “dry run” first to check for any potential issues.
  3. Test the Website:
    Once you’ve completed the above steps, test your website thoroughly. Check that all pages, posts, images, and other elements load correctly without any issues. Pay attention to internal links, media files, and any custom functionality.
  4. Update URL in Google Search Console:
    If your website is already indexed by Google, update the URL in Google Search Console to reflect the new domain.

By following these steps carefully, you can successfully move your WordPress website from the /wp subdirectory to the main domain, ensuring that your website functions correctly and maintains its SEO rankings. Remember to double-check all changes and perform thorough testing to avoid any potential issues.

Was this article helpful?
Dislike 0
Views: 87

Continue reading

Next: [Solved] HTTP Error When Uploading Media in WordPress
Get a Quote