WordPress has alot of flexibility when it comes to moving it’s core file and folder structure, or like in our case, to change the Wordpress directory name. For example, you may have a wordpress installation like domain.com/myblog and you want to change that to domain.com/mynewblog. There are a few options out there, but I will show you two solutions on how to achive this.
The most important thing before anything: Backup First!
Solution #1 – A fast way to do it (but not so safe in my opinion)
If you are a developer and you operate on non-live enviroment like localhost or a test server, then this is a solution for you. If you’re not comfortable with this, go ahead and look for my other solution.
- Open your FTP software (I use FilleZilla), navigate to your installation folder /myblog and change the folder name /mynewblog.
- Open and browse for the tool named “Search and replace” and get your download from this non-affiliate link
- Now extract the php file whitin the zip file you recived and as a precaution, rename the file with something unique (geodajk.php for example). Upload this file to your folder (the one you just renamed).
- Open the browser and enter the URL of the file uploaded in step 3. It should look similar to this: “https://domain.com/mynewblog/geodajk.php”.
- Once the page loads, click “Submit” and enter your database details in the text fields. On the next page, insert the old URL in the “search for” text field and the new URL in the “Replace with” text field. To continue, click the “Submit Seach String” button.
- Once this is done, go to your FTP program and delete the Search and Replace tool you’ve uploaded in the first place.
Solution #2 – Cloning your wordpress installation
If you don’t want to get messy with my previows solution, here is something that you can use to achive the same result (is not that complex as it looks).
- Login to your website, go to Plugins>Add new and search for “WP Clone by WP Academy”. Install, activate the plugin and navigate to Dashboard> WP Clone
- Click “Create Backup” and wait for the process to complete. After the process is complete, click “Copy URL” and save it for later use.
- Open your FTP software (I use FileZilla) and search for your root folder. Over there create a new folder with the desired name like /mynewblog and install wordpress as you normaly do. If you are a cPnel or Plesk user, use that to make a new worpress install (I will not get into that in this article).
- In your new wordpress installation add the WP Cone plugin like we did in step 1
- Now that you have installed the plugin, go to WP Clone, select “Restore from URL”, enter the URL saved in step 2 and click “Restore Backup”
- After the process is complete, you might need to instal a new plugin called “Better Search and Replace”. In “Search for” paste the old link domain.com/myblog/ and in “Replace with” enter the new path like domain.com/mynewblog/. Select all databases and If you’d like to skip de “dry” replacement, uncheck the last checkbox and click “Run Search/Replace”
- Now you can delete the old folder installation with FTP. Be aware not to uninstall and delete the old database as it is used for the new installation.
- Now you’re good to go!