Moving Wordpress to a new directory

If you've mistakenly installed Wordpress in the wrong directory, moving it to the correct directory can sometimes be a bit of a pain if you miss a step. A commonly encountered error is:

The requested URL /wp/ was not found on this server.

Let's assume Wordpress was installed at:

http://yourdomain.co.za/wp

We're going to change this to:

http://yourdomain.co.za

We can start by moving everything in /wp to the root web directory (/www or /public_html). If you're using cPanel, the simplest way of achieving this is by making use of the File Manager. Be sure to include hidden files when moving all files and folders out of /wp. This can be done by clicking on "Settings" on the top right in the File Manager, and ticking the checkbox reading "Show Hidden Files (dotfiles)".

hidden-1

You'll sometimes find that sneaky .htaccess when you view hidden files. Once moved, open your .htaccess file and replace any references to http://yourdomain.co.za/wp with http://yourdomain.co.za. Just be careful not to remove any redirects from /wp to the root web directory. I'd advise adding redirects after you have moved Wordpress to the new folder.

The next step is to update the siteurl and home column values in the database with http://yourdomain.co.za. In cPanel, click on phpMyAdmin, select your Wordpress database on the left side, and click on the table called options or tableprefix_options on the left side. You should see a table containing option_name and option_value. The two option_name's that we're interested in are:

siteurl and home

The option_value's for each of these should be changed to:

http://yourdomain.co.za

The option_values should read as follows:

siteurlmini

The final step is to ensure Permalinks have the same url structure as http://domain.co.za. To ensure this is the case login to your Wordpress admin area and go to:

Settings > Permalinks

You should just be able to click save without changing anything.

Your Wordpress installation should now be successfully serving from http://yourdomain.co.za. Should this not be the case, open wp_config.php in your root web directory and ensure all instances of http://yourdomain.co.za/wp are replaced with http://yourdomain.co.za.