Many web designers start a new website redesign project on the subdirectory of the existing website domain.
If you wish to move your WordPress website from a subdirectory (something.com/newproject) to main domain (something.com) then I bring you this “best way how to move WordPress from subdirectory to main domain”.
I have been doing this enough times to know what is the best process. If you are a beginner, it might be a bit confusing. There are too many tutorials over the internet and everyone says something else.
That is why I decided to show you the simple way how to move it and still stay sane 🙂
1. Create complete backup of the current website
Before you proceed to anything, back up the entire current website, including the database. If you don’t know how to back up a website, install the free plugin UpdraftPlus and launch the backup. Make sure you will connect this plugin with the storage (in the settings) where your backup files will be sent.
Make a backup of your development website (on the subdirectory) as well.
This is a necessary step to ensure that your data are safe in case anything goes wrong.
2. Change the domain name and domain URL in the WordPress settings
Log in to your WordPress website (the development project/on the subdomain) and navigate to the Settings → General.
Change the domain and URL name from subdomain to the main domain. Literally just delete the subdirectory after the “/” and save the settings.
After this, your website will be unavailable, but we will change it quickly.
3. Delete all folders from your public_html directory
Login to your web hosting account and navigate to the File Manager. If you know your login details to the FTP, then you can also use an online FTP client, but it is safer to do it through the web hosting account.
Once you are logged in to your FTP, navigate to the public_html – or any similar directory (“www”) where are stored files of your current, public, visible website.
Select ALL files except the folder which refers to your subdirectory where you have your new website.
Delete selected files. There should be only the folder of your subdomain website left.
4. Move all files from subdirectory to the public_html
Now open the subfolder file and select all files in there. Once selected, click on the “move” action in the upper menu panel. There should be a pop-up window which asks to what path you want to move files to.
You should fill in /public_html and click on the button “move files”.
Once it’s done, navigate back to the public_html path. You should see that all files from subdirectory moved there. Your WordPress development website has been moved to the main domain.
5. Repair old links
When you have been creating your website in the subdirectory, all your internal links, and medias were naturally linking to the domain with a subdirectory.
After the moving process, these links will not repair automatically, you have to help them.
You could do it by simple SQL “flush” in the database, but let’s not burden you with more advanced steps.
Install the free plugin called Velvet Blues Update URLs and open the plugin.
Update your domain URL with this plugin. Make sure to update all URLs so choose all of the checkmarks except the last one “update all GUIDs”.
The plugin will do all the work nicely. Your site should be now moved correctly and should work without any errors.
Did you manage to move your site from subdirectory to main domain successfully?
Let me know in case you have any issues during the process, I will be happy to help.
Was this post helpful to you? If yes, you can “buy me a coffee” and help me to manage the costs of this website.