Install WordPress in Subdirectory and Access It from Root
Posted on September 6, 2007
Filed Under WordPress Admin, WordPress Configuration |
WordPress provides a useful document for Giving WordPress its Own Directory While Leaving Your Blog in the Root Directory.
This feature is what I need when I run multiple sites in one web hosting account. My hosting service HostMonster gives me 1 free domain “richbase.com” hosted as core domain, plus unlimited add-on domains, one of which is this website “WordPressProfit.com”. Add-on domains are created as subdomains of the core domain internally but configured to work as the top-level domain.
By default, everything installed for core domain goes to the root directory /public_html/, and each add-on domain installation creates a subdirectory such as /public_html/wordpressprofit/. But I hate to have my core domain’s WordPress installation (about 30 WP folders and files) cluttered with my add-on domain subdirectories, that would be a maintenance nightmare.
Then the solution is to install my core domain, richbase.com in a subdirectory and configure it to be accessed from the root. In my case I created a subfolder /public_html/rbwp/ and installed WordPress from there. After installation, my core domain site can be accessed from:
http://www.richbase.com/rbwp/
Add all URLs of posts, pages, categories carry the subdirectory name /rbwp/, for example:
Post: http://www.richbase.com/rbwp/hello-world_1.html
Page: http://www.richbase.com/rbwp/about
Category: http://www.richbase.com/rbwp/category/uncategorized
But that’s not what I want. I want my core domain to be accessed from the root, like www.richbase.com. To configure this, login to admin panel, select Options tab, and go to General submenu. There are 2 important URL configurations:
WordPress address (URL): http://www.richbase.com/rbwp
Blog address (URL): http://www.richbase.com/rbwp
Simply change Blog address (URL) to http://www.richbase.com, that’s the URL address if you want your blog homepage to be different from the directory you installed WordPress. At this time, the site cannot be accessed from the root or the subdirectory.
Next, I need to copy the index.php and .htaccess files from subdirectory /public_html/rbwp/ to the root directory /public_html/.
The index.php in the root directory must be updated to require header from the subdirectory:
<?php
/* Short and sweet */
define(’WP_USE_THEMES’, true);
require(’./rbwp/wp-blog-header.php’);
?>
After the above changes, all URLs, — home page, posts, WP pages, categories, are accessed directly from the root:
Home: http://www.richbase.com/
Post: http://www.richbase.com/hello-world_1.html
Page: http://www.richbase.com/about
Category: http://www.richbase.com/category/uncategorized
The subdirectory /rbwp/ looks like disapreaed. Even the www.richbase.com/rbwp/ becomes unavailable. But admin pages such as admin panel and login page are still accessed from the subdirectory:
http://www.richbase.com/rbwp/wp-admin/
http://www.richbase.com/rbwp/wp-login.php
If you have a robots.txt file, make sure to put it in the root /public_html/. Don’t put it in subdirectory /public_html/rbwp/. Also add a line to this file:
Disallow: /rbwp/
Comments
Leave a Reply