Installing WordPress in a subdirectory, running it from the root directory

I may be completely alone in this, but I've never been a fan of installing anything straight in to the root directory on a web server. I've always opted for installing various bits of software in to their own subdirectories.

This has served me particularly well if I've needed to install several different bits of software on the same website, for example a piece of forum software to run alongside an existing CMS. Everything stays neat and tidy in its own subdirectory.

It also works really well for developing something new alongside an existing live enviroment. You can work peacefully inside the subdirectory, and even use .htaccess to restrict access to protect the innocent. When you're ready to go live, you can redirect traffic from your root directory to the subdirectory.

So I finally decided to publish my new website, and went about redirecting my root directory to the subdirectory where I had installed WordPress. I have my own method for doing this, but I decided to see what the official WordPress documentation says.

It details two main methods. The first method describes copying the index.php & .htaccess file to the root directory, tweaking the source code of the index.php file, and then changing the Site Address (URL) in Settings > General to remove the subdirectory. The subdirectory then becomes transparent to visitors, who would be able to browse the website on URLs such as http://marktyrrell.com/about.

The second method describes using a simple .htaccess file in your root directory, to redirect visitors to the subdirectory. Using this method, visitors would see the subdirectory in all URLs, you're simply redirecting anyone that lands on the root URL straight in to that subdirectory.

I opted to stick with my own method which I have been using for a long time, and works with various pieces of web software. To use this method with WordPress you first change your Site Address (URL) in Settings > General, removing the subdirectory to show something like http://marktyrrell.com. Ignore the error message you get after clicking save. You now create the following .htaccess file in your root directory (obviously modifying it to your domain and directory).

.htaccess
# Turn on rewrites.
RewriteEngine on

# Don't apply to URLs that go to existing files or folders.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Only apply to URLs that aren't already under /wp.
RewriteCond %{REQUEST_URI} !^/wp/

# Rewrite all those to insert /wp.
RewriteRule ^(.*)$ /wp/$1

# Redirect the root folder.
RewriteCond %{HTTP_HOST} ^(www.)?marktyrrell.com$
RewriteRule ^(/)?$ wp/ [L]

Importantly, clear your web browser cache and delete any cookies for the domain. After you've done this navigate to your website root directory, and you should see your WordPress installation sans the subdirectory in the URL.

I prefer this method as I wasn't too keen on copying and modifying the index.php file. If anyone knows of any potential drawbacks to my method, or why going down the modified index.php route is better, drop me a line in the comments.

My Top 5 WordPress Plugins

The thing that really makes a CMS in this modern day is the plugins & add-ons available to enhance and customise it to your own specific needs. Here are my current top 5 add-ons for WordPress.

  1. Akismet

    Within a week of making a blog available to the Internet I started getting spam comments! This plugin (which as far as I know comes with WordPress as standard now?) helps fight back against spam! It’s a must have for any WordPress bloggers. If you intend to open comments up without moderation this plugin will do you a big favor. FYI, you’ll need a WordPress.com API key to use it.

  2. FeedBurner FeedSmith

    I love FeedBurner. FeedBurner FeedSmith is the plugin that Google actually recommend to use FeedBurner with WordPress and with good reason. Activate it, enter your FeedBurner feed URLs in to the configuration page and your done. No changes to your WordPress theme needed, it redirects your ‘old’ feed URL to the FeedBurner URL so you can even use this to implement FeedBurner feeds on an already established blog. Magic!

  3. Configurable Tag Cloud

    So tagging is the next big thing on the Internet. Everyone is doing it and if your using WordPress I bet you are too! I was quite disappointed with the stock tag cloud widget for WordPress. I was hoping I would atleast be able to configure ‘hot’ and ‘cold’ colour for it, but I found all I could change was the title… bummer. So straight away I hit the WordPress plugins library and found Configurable Tag Cloud (CTC) straight away. It gave me exactly what I wanted straight away, colours! You can also set the maximum number of tags to display, smallest & largest font size, whether to display categories in the cloud, whether to display the post count next to tags… enough? In my opinion this is another must have considering the complete lack of configurability provided for the stock widget.

  4. Sociable

    This little gem allows you to put those little 16×16 icons at the bottom of your wordpress posts to allow users to share & bookmark your posts at their favorite social bookmarking websites. There are 99 different social bookmark sites you can choose from and you can also fine tune where they appear including in your RSS feeds! It’s pretty much ‘plug & play’ in the sense you can install it and use it with minimal configuration. Alternatively, you can also get your hands dirty and customise it with replacement icons and your own CSS.

  5. Google XML Sitemaps

    Some of you may dispute the importance of an XML sitemap, some of you may swear by them for SEO. This plugin will generate one for your wordpress blog every time you make a new post. If it’s that easy you might as well have one right? It’s highly customisable and even has options to notify major search engines everytime the sitemap (and ofcourse your blog) is updated.

Archives

2012
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2011
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2010
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec