You’ve decided to make a change to your existing WordPress setup and move it to the root directory, but don’t want to damage your blog in the process. Many webmasters and bloggers have had to change their setup over time, it isn’t uncommon. Whether it be due to structuring issues or maturing of the website, WordPress makes the process mostly simple.
The official codex explains the process well, though it could use a little more detail and step-by-step type instruction for those unfamiliar with the process. That’s what I’ll be addressing in this post. This move was accomplished on WordPress 3.4.1.
- First and foremost, review the Moving WordPress codex. It will familiarize you with the steps and options involved with moving your WordPress site.
- Ensure you have FTP access and working login credentials. Adjusting the location of files is more standardized in terms of explanation when FTP connections are used.
Note: If you are familiar with cPanel’s File Manager, then you may want to use that since it is generally quite fast.
- Backup your WordPress site. Include the database as well as .xml exports.
- Familiarize yourself with How To Use Velvet Blues Update URLs plugin.
Before You Begin
- Examine the root (/) directory of your site and look for an .htaccess file.
Note: It will be hidden by default, so you may need to instruct your FTP client to display hidden files. If one exists (and it should, even if it’s empty), download the file to a unique directory on your computer.
- Search through the remaining files in your root directory for any with the same name as those in your current WordPress directory (Example: /blog, /wordpress, etc.). If any exist, download them to their own unique directory on your computer. Doing so makes them easily accessible later on if you need to make changes.
- If you wish to preserve the files in your root directory for archiving purposes, now is the time to download them all.
Note: Once you begin to move your WordPress files, those in the root directory will be overwritten if they have the same name (Example: index.php). Files with unique names will remain in the directory.
- Optional: Download all files and folders from your existing WordPress directory to a unique folder on your computer. I recommend this for anyone archiving their old setup. I also find it more straightforward for FTP file movement.
- From your WordPress dashboard, navigate to Settings → Permalinks and make note of your existing permalink structure.
How To Move WordPress
- Login to your WordPress dashboard as an administrator.
- Login to FTP, cPanel or whatever you’re using to move your files.
- From your WordPress dashboard, navigate to Settings → General.
- Change both WordPress address (URL) and Site address (URL) to the new location for your WordPress site. Example: http://domain.com would be the new URL for moving your wordpress site to the root directory.
Note: This step must be done before moving any files to ensure users can log back into their WordPress dashboard.
- Click save changes.
- From your FTP client, access your WordPress files and folders. Example: Moving from /blog to the root directory you will access all files and folders inside the /blog folder, but not the blog folder itself.
- Move all files and folders from inside the /blog (or wherever your WordPress files are) to the root directory.
- When movement of all files is complete, check the old folder location (/blog or similar) for any remaining files. It should be empty. If not, remove the leftovers (download them to your computer if you didn’t already download the old WordPress directory for archiving purposes).
Note: Download of any extra files is simply precautionary in case they were missed in the move and you need them later on.
- Login to your WordPress dashboard at http://yourdomain.com/wp-login.php
Note: The wp-login.php file has moved to your root directory.
- On the WordPress Dashboard, navigate to Settings → Permalinks.
- Update your permalinks to your preferred structure (as previously noted).
- Click Save Changes.
- Update media links and folders. There is an easy way to accomplish this by using the Velvet Blues Update URLs plugin. Follow this guide.
- Update any menus you’re using on your WordPress site to reflect the directory changes.
- At this point you can view and test your WordPress site. If everything was done properly, then you should see your old site just as it was now on the main domain.
Post Move Instructions
If everything went perfect, then you don’t have much to do. However, it’s a good idea to check a couple things to make sure.
Check File Permissions
Before the move, most should have been 0644. If any are shown as 0000, then make sure you adjust them.
Combine .htaccess files
The WordPress .htaccess file was moved to the root directory and contains special instructions for plugins, permalinks and other WordPress specific arguments. You must combine that file with the other (old) .htaccess file which you downloaded and saved earlier from the root directory. Open them both up in a text editor (Notepad, gedit, etc.) and copy the contents of the old .htaccess file into the new one.
- Copy the contents of the OLD .htaccess file into the new .htaccess file beneath everything else.
- Add the following line to the .htaccess file, replacing yourdomain.com with your new WordPress domain address and replacing /blog/ with your old WordPress location:
redirect 301 /blog/ http://www.yourdomain.com /
- Save the file and upload it to the root directory. Confirm overwrite of the file.
Note: If you’re comfortable modifying the .htaccess file by hand, then now would be a good time to tidy it up with annotations and remove any outdated or duplicate information.
- Check redirects. The easiest way to check this is to enter the old URL of your WordPress site into the address bar. If the 301 redirect information was entered correctly it should send you to your WordPress site at the new URL.
Some plugins may rely on URL structure and will need to be updated. As an example, automated backup plugins may require you to update your file retrieval directory.
Adjust Webmaster Tools
Google will automatically crawl your site in its new form, but to speed the process along, you can resubmit your new sitemap. The same holds true for Bing and other webmaster tools services.
Even though everything is supposed to go off without a hitch, sometimes there are problems. Here are some quick troubleshooting tips if you run into trouble.
- If you’re moving a site locally, be sure to reboot the server if changes don’t take effect.
- If menu links return 404 or other error, navigate to Appearance → Menus and check all links begin with http://yourdomain.com/ or create custom links to manually enter the domain location.
- If links and images aren’t directing properly,run Velvet Blues Update URLs again. Double-check that the proper file structure is chosen.
- If for some reason Velvet Blues Update URLs doesn’t work or is unavailable at the time of your move, review our Troubleshooting Tips or try Search and Replace plugin.
If you enjoyed or found this article useful, please show us some support by liking us on Facebook or by sharing us on your favorite social website. Thanks!