RSS Feed

Hidden Treasures

Bizquarium's Treasured Recommendations
Like what you see here? Subscribe to updates via RSS or email...

Keep it clean: Install WordPress in a subdirectory

When installing WordPress to manage your brand new website, you’ve got two choices: either install it to the root directory or install it to a subdirectory.

I’m talking about where the actual files are located. In both cases, you’ll be able to setup your WordPress site so that it works at a location like

The Pros and Cons of Subdirectories

There are a couple of major advantages I see to installing WordPress in a subdirectory:

  • It keeps your web root folder neat and tidy. If the needs of your website are anything like this one you’ll want the freedom and flexibility to introduce other web applications into the mix without making a big mess of your file structure. Putting WordPress in its own folder tucks almost all of the files associated with it away in a simple and clear location.
  • It makes it easy to add an additional layer of security to your admin directory. Well, that is unless you are stupid enough to write about it as I’m doing. The security bonus is accomplished by renaming your WordPress subfolder to something that is hard to guess, making it more difficult to hack into.

Here is how you get it done

First, you are going to want to install your WordPress blog per the standard WordPress instructions. The only difference here is that you’ll want to make a subdirectory to install to instead of installing directly into the root folder of your website. While the natural name for this subfolder would be wordpress or wp I like to make it a little bit harder to guess and make it something a bit more unique. Here at Bizquarium I have used _wp (shhh! Please keep my secret folks!).

Then you are going to want to move (not copy) the index.php file from the main folder of the WordPress install to the root of your website and open up it in a text editor. You’ll need to change the path on line 4 to look like this:

Changing the include path in WordPress

Of course, instead of _wp use whatever super-secret folder name you picked.

Next, you need to login to the WordPress administrator. Remember, that is going to look something like:

Once you are logged in head over to Options > General and change your WordPress Address (URL) so that it includes the folder name you used. When you are done it should look something like this:

Setting the subdirectory in WordPress

That’s it! You should be all done and ready to really get cooking with WordPress.


  1. Andy Corps - March 10, 2008 - 6:54 am

    Nice one. Cheers for this. So simple, I didn’t realise. I was looking for something more complicated. ha ha

  2. Dz - March 13, 2008 - 6:32 pm

    Hi — thanks for the post!

    Incidentally, you will have to copy the .htaccess file from your wordpress directory if you want pretty permalinks to work! Cheers!

  3. Adam Kayce - July 2, 2008 - 7:31 am

    You mention “Pros & Cons” up above, but then never say any “cons”… is that on purpose? ;-)

  4. Clearly Biased - September 25, 2008 - 6:34 pm

    I already have a “index.php” in my root. How do I handle this conflict? I run a Joomla! site and have installed WordPress in a “” subdirectory. Any and all comments welcomed.

  5. Cyn - September 30, 2008 - 12:14 pm

    I think this is a great idea, as keeping it in a subdirectory makes things cleaner. BUT it does not make it more secure. If you look in the source code, people can still find out which directory you installed it in.

    Any way to work around it?

  6. Mark Blair - September 30, 2008 - 1:12 pm

    @Cyn — I see I should have clarified that better — the security benefits here would be more to help prevent against automated attacks that may assume a typical WordPress installation.

    Just one more roadblock in their way :-)

  7. tom - November 11, 2008 - 3:19 am

    Hi, I’m having a problem and tried your fix but it still doesn’t work. When i click links in my blog it loads up my index page.

    If i mouse over a link in my blog e.g. “comments” i will see in the browsers bar at the bottom left corner:

    ww w.3dmaxit.c om?p=1#comments when it should be:
    ww w.3dmaxit.c om/Blog?p=1#comments (i think)

    Please help me :S

  8. Mark Blair - November 11, 2008 - 12:01 pm

    @Tom – Since it looks like you want your blog to be accessed at, you really can just install WordPress normally in a folder called “blog” off of your root. By keeping it in the folder called ‘blog’ it will keep your domain root clean and be accessible at the location you desire. This advice was aimed at people that want their blog to be the home page of their site.

    If you want to keep your “blog” folder uncluttered, I believe you can do exactly the same steps above but use these in your options > General instead of what is listed above:

    WordPress Address (URL):

    Blog Address (URL):

    However, you really don’t see a lot of benefit to this other then that of obfuscating your installation somewhat to reduce automated, scripted attacks.

  9. tom - November 11, 2008 - 7:59 pm

    Hi, thanks for your response.

    It still doesn’t work, when i click on comments or uncategorised etc i get this:

    Just a non css styled version of an empty page of my site. :(

    I want my blog to be accessed separately to the rest of the site, I’ve made a button at the bottom of the page on the left side called “Blogs”.

  10. Mark Blair - November 11, 2008 - 8:31 pm

    @Tom – I just dropped you an email with a recommendation. Basically, I think for you that you will want to go for the default install unless I am misunderstanding your needs.

  11. tom - November 11, 2008 - 11:47 pm

    Hi Mark,

    Thanks for your email, your help is much appreciated.

    Found out the problem is that i needed to make a .htaccess file in the new directory and have the line:

    DirectoryIndex index.php

    Thought id comment here rather than email in case anyone else has this problem.



  12. Mark Blair - November 12, 2008 - 12:41 am

    @Tom – Thanks for reporting back and glad to hear you got it working!

  13. aceblade - November 29, 2008 - 7:23 am

    Hey Mark, I’ve read recently that it’s best to keep your blog in the root folder if you have no other content to offer. Am I losing anything by keeping my blog in a subfolder with a welcome page located in the root folder? I’m not offering anything on my main site except my blog, but I’ve read twice now that it’s a “mistake” to do that. What are your thoughts?

  14. Mark Blair - December 3, 2008 - 2:30 am

    @aceblade – In general, if all you are going to have on your website is a blog then 100% of your visitors that access your website by keying in your domain are going to need to click through your welcome page to get to your blog.

    In general, it is a bad idea to put people through unnecessary clicks online. You are likely going to lose some percentage of visitors along the way.

    In your case, unless you plan to add additional content to your website at some point, I’d say leading with your blog is an easy decision.

    This post explains how you can do that and keep WordPress in a subdirectory “under the hood” so that you can keep the file structure on your server a bit cleaner.

  15. Adam - December 6, 2008 - 5:41 pm

    Oh boy… I just moved my .htaccess and index.php, and when I went to change my General Settings, I removed the folder name instead of adding it – and now I can’t get back in.


  16. Adam - December 6, 2008 - 5:59 pm

    Ah, never mind – got it fixed from this:

  17. Beau - December 17, 2008 - 2:16 am

    Thanks, this was exactly what I was looking for! I managed to follow the instructions and had it working within minutes…

  18. Richard Whyte - January 27, 2009 - 10:54 pm

    Another way to do this and keep it clean is install the WP Blog in whatever directory you want.

    Then create an index.htm file in the root and place a redirect statement in it. As soon as someone gets to the root it will bounce them instantly to the blog. It is only one line of code…

    A complete index.htm file looks like this:

    (BIZQUARIUM: Sorry, HTML doesn’t come through in the contact forms — I’m assuming you were talking about adding a meta refresh here. There are a number of drawbacks to consider using this approach. For example as search engines, etc will resolve to whatever directory you put WordPress in. Also, your directory will be included in your permalink paths and every other fixed reference generated by WordPress. Still, this method is useful in some circumstances. For example: if you are in a situation that you are building both a website and a self-contained blog but are starting with the blog first. Then, you can install the blog in the directory you want to keep it in and redirect your domain root to the blog until you have built your website)

    Very fast, very easy and you never have to worry about it again. If you keep the new index.htm file this small, the visitor won’t even see it as it is so small it will load and vanish faster than a blink of an eye!

    Hope that helps you out!

3 Trackbacks

  1. […] if you are like me and have WordPress installed in a subdirectory to keep thing clean you’ll need to fix another glitch on lines 279-281 by […]

  2. […] Keep it clean: Install WordPress in a subdirectory : BizquariumHow to keep your WordPress directory in a subdirectory of your web site instead of dumping all those wp-* directories into your root. Nice! […]

  3. […] possibility of your blog becoming an unexpected hit. For this reason I sometimes set up the blog in a seperate blog subfolder in the site, instead of installing it in the root directory if I anticpate that it will be popular amongst […]