confessions of a web developer
Wednesday, February 3rd, 2010
I wanted to take back my home directory and decided to move WordPress to it’s own folder. WordPress fully supports this but it is usually easier when you are first installing WordPress, then later on down the road.
The first thing we have to do is login to the WP-Admin area. Go to Settings and under WordPress address put www.domain.com/wordpress/ Leave the Blog address at just www.domain.com Now once you press Save Changes your site will be broken, but don’t worry it’s only temporary. The important thing is that pressing Save Changes sent the change to your mySQL database before your site broke.
The next step is to move all your WordPress files into a subfolder, except for the index.php files and .htaccess. Moving the WordPress files were easy enough, you just create a subfolder in your home directory named wordpress. The directory can actually be named whatever you wish, but for our purposes we will just call it wordpress. Not edit the index.php file in your root directory to have it include the file from your new directory.
Before the change:
/** Loads the WordPress Environment and Template */
require('./wp-blog-header.php');
After the change:
/** Loads the WordPress Environment and Template */
require('./wordpress/wp-blog-header.php');
Once this is done your site should be backup and running again. The one problem you may notice is that images in your posts may be missing. That is because most of your posts are looking for images from the root /wp-content/uploads/ folder which has been moved. Rather then edit through each and every post to change the path, there is a simply SQL command to run on your WordPress database to fix the problem.
UPDATE wp_posts SET post_content = REPLACE(post_content, 'your-domain.com', 'your-domain.com/wordpress');
There you have it! You’ve successfully moved your WordPress installation to it’s own directory and reclaimed your root directory for easy management. If you had any problems with this or you know of a better solution please leave a reply in the comments.
Tags: mySQL, php, Security, Wordpress
Posted in Web Development | No Comments »
« Top Ten Movies of 2009 | My name is Chris Blackwell, and I AM CANADIAN »