Change WordPress Directory

Do you have a website that you would like to move to a directory? Or do you have a site in a directory and would like to move it to the main folder of your domain?

Surely you have seen yourself reflected in the previous questions, because it happens more frequently than expected.

In this article we will see two ways in which you can carry out this process.

The first of them consists of use the tools of your hosting accountthe other is one manual way in case you have made a transfer of your site from another server or have installed your site manually.

Using the tools of the Hosting account to change directory.

The idea of ​​this method is first make a clone of your website, which will be an exact copy of your site in another location and after checking that everything works correctly, delete the original site.

From the Cpanel of your hosting account locate the section Websites Are Us applications and then the application called WPCenter, as shown in the following image:

Cpanel wpcenter tool

Then a list will appear with the websites that have been installed in your hosting account using the Websites Are Us applications.

List of WPCenter sites

You will see that for each registration you have an option to configure, access that option, then at the bottom you will see that you have an option to clone the site.

WPCenter Cloning Option

By accessing the option cloning You will see a screen similar to the one shown below:

WPCenter Cloning Screen

  1. You must enter the domain in which you want to have the cloned website, if you have more than one domain you must select the one you want.
  2. Write the path where the clone will be made, if you want to have the new site directly in the domain then just leave /
  3. Finally click on the button start cloning to start the process.

At the end, a screen will appear indicating that the process has finished and a link to access the new cloned website:

clone finished

All right, you already have a clone of your site, now it only remains to delete the original website.

If the site has been installed with the Tools of your hosting account you can simply access the section>Websites Are Us applications and then in>Start.

Start Option Applications

Then you will see the installed applications, in our case we only have one, we use the button options to see the application detail:

Installed apps

The detail of the application will appear from where you can delete it, as shown in the following image:

Delete an installed application

Change WordPress directory manually

First we will move the files from the source directory to the new directory, you can use the application of the File Manager from your Cpanel, as shown in the following image:

File Manager Tool

Locate the folder where you have the website files, and then move them to their new location.

Define path to move files

  1. Choose All the filesmake sure the hidden files like file .htaccess also be selected if you don’t see the file .htaccess, use the configuration option to see the hidden files.
  2. Use the option Move, a popup will open.
  3. Change the destination path, and finally use the button Move Filis.

Make sure the source folder is empty, then you can select and delete it.

Delete source folder

We will make a modification to the file .htaccesswe use the File Manager to locate and edit the .htaccess and delete all references to the previous folder, as shown in the following image:

.htaccess file modification

Now only remains make the changes at the database level since WordPress stores the absolute urls, that is, we have urls that still include the path of the folder in the database.

To do this We will use the Database Search and Replace Script in PHP script.

When entering the website we will have to register, since the script link will be sent to us by mail:

Script form

Once the file is downloaded, you can upload it to the server using the File Manager from your Cpanel from your hosting account.

Unzip script

  1. Upload file Search-Replace-DB-master.zip to the folder where you have the files for your website.
  2. Select the file to unzip it.
  3. Use the option extract to unzip the fileBy default, a folder with the same file name will be created.

Access the script folder from the browser based on the url of your domain, as shown in the following image:

script url access

Then the script interface will appear, as shown in the following image:

Screen run script

  1. In the field of Replace put the previous url (in our case the url with the folder), and in the field With put the new url, make sure that both urls do not have / at the end
  2. Fill the connection data to the databaseong>. These data can be obtained from the file wp-config.php from your website. Use the option Text ConectionYou should see a green message confirming that you have successfully connected.
  3. Optional: can you make one replacement test. This option simply performs a search and lists all matches but does not make a replacement yet.
  4. Once you’ve made sure there are urls to replace, you can make the replacement of the urls in the database.
  5. Finally you can delete script. This option does not always work so, make sure it’s actually removed since leaving this folder is a security problem.

Delete the script manually in case it has not been eliminated with the previous option.

You can verify it using the File manager from your Cpanel, as shown in the following image where we delete both the folder and the file .zip

Select script folder and file