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.

 

From a subfolder to root on the same domain.

1. Create a Complete Backup of Your Website

This can be done using the DirectAdmin control panel, The Softaculous auto installer (if you have installed WordPress using Softaculous) or you can use a WordPress plugin for automated backups. Note that WordPress plugins only backup the WordPress installation. All other content or e-mail is ignored

 

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.)?example.com$
RewriteCond %{REQUEST_URI} !^/my_subdir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /my_subdir/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ my_subdir/index.php [L] 

change example.com and my_subdir to the correct values.

That's it! Your WordPress site can now be accessed at yourdomain.com. The admin login page however is still located under yourdomain.com/my_subdir/wp-admin

 

1.2 Moving your WordPress Files From Subdomain to Root Folder.

  • 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.
  • 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.
  • Login to WordPress in the root directory. This can be found at yourdomain.com/wp-admin.
  • Go to Settings > Permalinks and click Save Changes. This will rewrite your .htaccess file to remove the subdirectory from the page URLs.
  • 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 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.

  • Test the site and be sure everything is appearing as expected.
  • 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.
  • 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. (Note: .htaccess is an invisible file. You must select in the File Manager or FTP client to show invisibles in order to see this file.)
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain.com/subdirectory$ [OR]
RewriteCond %{HTTP_HOST} ^www.mydomain.com/subdirectory$
RewriteRule (.*)$ http://www.mydomain.com/$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.

Pro tip: To start, set this rule to 302 instead of 301 and test it to make sure it is working by entering one of your URLs with the subdirectory in it and make sure it rewrites to the same URL without the subdirectory. When you are sure it is working, change the 302 to 301. 302 is considered temporary and is not used for SEO and is not cached by browsers. 301 is considered a permanent change and is considered by Google to transfer the SEO credit of a page from one URL to another and is cached by browsers.

  • 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...