Run WordPress Blog from Root Directory but Install to Subdirectory

Posted by Drothism on May 30th, 2007

I was setting up http://www.drothism.com and trying to figure out if I should put this blog in a subdomain, subdirectory, or just dump it all in the root of the site. SEO tips suggested that the blog should appear to be in the root of the domain but I didn’t like the idea of dumping all the WordPress files into the root of my site. To run WordPress from the site’s root directory (eg. http://yoursite.com) but to avoid WordPress files cluttering the root directory, it is possible to install WordPress files into a subdirectory. Installation and configuration is shown in this post and will work for both new and existing WordPress installations.

Many people want WordPress to power their site’s root (e.g. http://example.com) but they don’t want all of the WordPress files cluttering up their root directory. WordPress allows you to install the WordPress files to a subdirectory, but have your blog exist in the site root.

The process to move WordPress into its own directory is as follows:

  1. Create the new location for the core WordPress files to be stored (we will use /wordpress in our examples).
  2. Go to the Options panel.
  3. In the box for WordPress address (URL): change the address to the new location of your main WordPress core files. Example: http://example.com/wordpress
  4. In the box for Blog address (URL): change the address to the root directory’s URL. Example: http://example.com
  5. Click Update Options. (Do not worry about the error message and do not try to see your blog at this point!)
  6. Move your WordPress core files to the new location (WordPress address).
  7. Copy the index.php and .htaccess files from the WordPress directory into the root directory of your site (Blog address).
  8. Open your root directory’s index.php file in a text editor
  9. Change the following and save the file. Change the line that says:
    to the following, using your directory name for the WordPress core files:
  10. Login to the new location. It might now be http://example.com/wordpress/wp-admin/
  11. If you have set up Permalinks, go to the Permalinks panel and update your Permalink structure. WordPress will automatically update your .htaccess file if it has the appropriate file permissions. If WordPress can’t write to your .htaccess file, it will display the new rewrite rules to you, which you should manually copy into your .htaccess file (in the same directory as the main index.php file.)

Leave a reply

You must be logged in to post a comment.