Wordpress in its own Directory

So as times go by, and I began adding more domains and subdomains to my hosting, I’ve come to the conclusion that it was getting crowded. I deleted over half of my subdomains that I wasn’t using since they were used mainly for client use, and my root folder was getting messy. Naturally I didn’t care about that until the last 2 hours when I suddenly got irked by it, so I researched on how to move wordpress to it’s own directory, and I’ll give you a review of the process step by step instead of you having to read through some mess.

Step 1 – Making your folder

The first thing you want to start with is to make the directory folder that you want your wordpress files to go into. Some people call it blog, site, wordpress, or for security reasons, give it a name that has nothing to do with your site. The reason for that is because all wordpress admins are usually accessible by going to “/wp-admin” address of your site. To further protect your site and blog, why not give those hackers a hard time finding where you stored your files?

Step 2 – Go to your Wordpress Admin Settings

The next thing is to tell wordpress where you’re going to move it. So access your admin just like normal, and go to Settings > General and do the following.

Wordpress address (URL) – The URL of the folder that you just made in Step 1. So if you made a folder called blog, then you put in http://yourdomain.com/blog.

Blog address (URL) – The URL of your site. So if you want your Wordpress blog/site to show up when they go to http://yourdomain.com, then you put http://yourdomain.com in there.

Save changes, and you’ll get some ugly stuff going on. Don’t worry about it, the settings are saved, and now that you told Wordpress that it’s located somewhere else, it’s trying to find the files in that place, but we haven’t moved it yet so that’s why you get the ugly stuff.

Step 3 – Moving the Wordpress Files

Now simply move all Wordpress related files into that new folder. The files you will be moving are listed below:

  • wp-admin
  • wp-includes
  • wp-content
  • All files with wp- in front of the file name such as wp-config.php, wp-feed.php, wp-rss.php, etc…

So basically all Wordpress files except for index.php and .htaccess (if you have one). Leave those behind in the root directory.

Step 4 – Editing index.php to redirect to the right place

If you checked out your site, you’ll probably see an unstylized form of your blog, so the next thing to do is to tell that index.php that you left in the root where your Wordpress files are located.

Go to your root directory and open/edit index.php with Notepad or any text editor. You’ll notice the following line:

require('./wp-blog-header.php');

Now you want to edit that to reflect the new place you put that Wordpress file, so just simply add the folder you made in front like so:

require('./blog/wp-blog-header.php');

And save that to your FTP, transfer it, or whatever you do to normally upload files to your hosting, and you should be good to go.

Problems with doing this Move

So if you’re like me, and just did this thinking everything was fine with your old posts….you got a lot heading for you. Only do this if you’re content with the following:

Leaving all the image uploads and attachments in the root
or
Going through all your posts and linking them to the right place.

So I ended up doing the latter, and it was a pain to go through all my images to add an extra directory to all my links. If any of you guys know a better way to do that, then comment or leave a link to a tutorial or article about it, since that would be a lifesaver in the future.

Anyway, just showing my little experience with moving it to another directory and the problems that existed. Just follow the steps above and everything will go smooth.

Add a Comment

Your Comment