How to move my WordPress installation

If you spend a little time preparing your own website, migrating is nothing to be concerned about. It can be a very straightforward project if approached correctly and can easily be reversed out of should any problems occur.



1. Move WordPress from a subfolder to root on the same domain


1.1 Without moving your files:

If you do not wish to move your files you can create an .htaccess file in the root folder (public_html) of your hosting account.

The .htaccess file should contain the following:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?$
RewriteCond %{REQUEST_URI} !^/my_subdir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /my_subdir/$1
RewriteCond %{HTTP_HOST} ^(www.)?$
RewriteRule ^(/)?$ my_subdir/index.php [L] 

change and my_subdir to the correct values.

That's it! Your WordPress site can now be accessed at The admin login page however is still located under


1.2 Moving your WordPress Files From Subdomain to Root Folder.

  1. Login to WordPress and head to Settings > General and remove the subdirectory from the URL for both the WordPress Address and Site Address. Be sure to remove the trailing /. Click Save Changes when done.
  2. Move all your Wordpress files from the subdirectory to the root level directory using FTP or the DirectAdmin File Manager. The root level directory is named public_html.
  3. Login to WordPress in the root directory. This can be found at
  4. Go to Settings > Permalinks and click Save Changes. This will rewrite your .htaccess file to remove the subdirectory from the page URLs.
  5. Install the Velvet Blues Update URLs plugin and follow the instructions below:

    • Under Tools > Update URLs, type the website address containing the subdirectory in the Old URL field and the website without the subdirectory in the New URL field.
    • Be sure to not end the URLs with a forward slash /. If you do end it with a forward slash, end it with a forward slash for both URLs not just one. Consistency is important here.
    • Be sure to NOT update all GUIDs. This will result in many theme settings to reset and posts to republish to the RSS feed.
    • Click the Update URLs button. This should catch most of the URLs on the site. However, if it seems to miss several, you can try repeating this process without the http:// part of the URL, and see if it catches more.
    • Check for other URLs not caught with the Velvet Blues plugin including:

      Appearance > Menus - check for any custom URLs to the old site URL in any custom menu items, such as the home page link.

      Appearance > Theme Options or your theme’s Theme Options page - check the URLs for any uploaded files such as the logo or favicon and remove the subdirectory from the URLs as needed.

      – Sliders — If you use Revolution Slider or other slider plugin may not update the URLs to the slider images with the Velvet Blues plugin. Edit the slider and remove the subdirectory from any image URLs.

      – Shortcodes and custom layouts — Some shortcodes for button links or custom theme layouts may contain URLs to the subdirectory which you may need to manually change. If you can find a pattern to these, you can try to run the Velvet Blues plugin again using the URL pattern you find.

  6. Test the site and be sure everything is appearing as expected.
  7. Reset caching plugins and update the .htaccess file per the caching plugin instructions as needed. Test the site again in a different browser to be sure the pages are caching correctly.
  8. Finally, to keep from losing all your SEO credit on the old site, you will want to implement a wild card redirect from the old URL to the new one. To do this, add the following bit of code to the top of your .htaccess file using the File Manager or FTP application substituting YOUR domain name and subdirectory name.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^$ [OR]
RewriteCond %{HTTP_HOST} ^$
RewriteRule (.*)$$1 [R=301,L]

On the RewriteRule line use www or don’t use www according to what you have in Settings > General. For example, if you don’t have www in your URL in the General Settings, do not include the www in the RewriteRule line.




2. Move WordPress to new domain


Moving a website and changing your domain name or URLs (i.e. from to requires the following steps – in sequence:

  • Download your existing site files.
  • Export your database – go in to MySQL and export the database.
  • Move the backed up files and database into a new folder – somewhere safe – this is your site backup.
  • Log in to the site you want to move and go to Settings > General, then change the URLs. (ie from to – save the settings and expect to see a 404 page.
  • Download your site files again.
  • Export the database again.
  • Edit wp-config.php with the new server’s MySQL database name, user and password.
  • Upload the files.
  • Import the database on the new server.

When your domain name or URLs change there are additional concerns. The files and database can be moved, however references to the old domain name or location will remain in the database, and that can cause issues with links or theme display.

If you do a search and replace on your entire database to change the URLs, you can cause issues with data serialization, due to the fact that some themes and widgets store values with the length of your URL marked. When this changes, things break.

To avoid this data serialization issue, you have three options:

  1. Use the Velvet Blues Update URLs or Better Search Replace plugins if you can access your Dashboard.
  2. Use WP-CLI’s search-replace if you have installed WP-CLI.
  3. Use the Search and Replace for WordPress Databases Script by to safely change all instances on your old domain or path to your new one. (** only use this if you are comfortable with database administration ** )



  • wordpress
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Comment / forum spam and how to stop and fight it

This guide explains forum or comment spam and gives quick general tips on how to limit both...

How do I Write a New Post in WordPress?

  WordPress is one of the most popular blogging platforms for a lot of different reasons. One of...

How do I Update my WordPress Installation?

  This tutorial will teach you how to update your WordPress installation. You should be logged...