How to Install WordPress on a sub-directory or sub-domain
Posted on 08. Sep, 2009 by Jay in Blogging
One of the questions I get asked the most by online marketers and new bloggers is how to install WordPress in or move to a sub-directory or sub-domain but still have it show as the default website for the domain. To clarify: install in blog.mydomain.com or mydomain.com/blog and still have it show as www.mydomain.com.
The main reason for this is to leave the possibility of adding other applications in sub-directories (like forums, affiliate scripts, review sites in sub-domains), to add later static HTML pages or a CMS (Content Management System) site as the main site with the blog linked on the back end. It also keeps your root directory neat and clean!
In order to accomplish this you will need to install WordPress in a sub-directory (ie. blog) as you will do normally on any domain. This means creating a database, uploading the WordPress files to the directory (ie. blog) and visiting with your browser blog.mydomain.com or mydomain.com/blog. If you use an automated system like cPanel, first create a folder (ie. blog) and define it as the directory for installation.
If for some reason you can’t change the directory or have already installed the blog on your site root directory (httpdocs, www or htdocs), don’t worry, I will show you how you can move it and what you need to change.
Scenario 1 – You installed on a sub-directory named “blog”:
1. Move your index.php file from the sub-directory where you installed your blog to the root (main) folder of your site. This can be done using cPanel, your hosting website manager or using an FTP program like Filezilla. You should also be able to edit the file using these alternatives.
2. Open the index.php file and edit this line:
index.php file
All you need to do is tell it how to find wp-blog-header.php in its subdirectory. For example, here’s what the code would look like if I installed WordPress in a directory called “blog”.
index.php-edited
Notice I simply added /blog just before /wp-blog-header.php, that’s all the code editing you have to do.
3. Move the .htacces file from the sub-directory where you installed your blog to the root (main) folder of your site. This is needed in order for your blog to use beautifull search engine & human friendly URL (web addresses) like: mydomain.com/blog/how-to-do-ppc intead of mydomain.com/blog/?id=page234.php.
4. Login into your blog as Admin(http://www.mydomain.com/blog/wp-admin/).
5. Once you are logged in head over to Options > General and make sure your WordPress Address (URL) includes the folder name you used (ie. “blog”), if not add it. If using subdomain use blog.mydomain.com if not mydomain.com/blog.
The Blog Address (URL) should be your main domain like http://mydomain.com without the “blog” folder, if not, change it. When you are done it should look something like this:
WordPress-URL-settings
That’s it! Your blog will show up as your main site and you will be able to use whatever other apps (pop-ups, squezee pages, forums, etc.), minisites or sub-sites on your domain.
Scenario 2 – You installed it on the main site:
a. Create a sub-directory (ie. blog)
b. Log into your blog as Admin follow step #5 above. When you click “Update Options”, do not panic about the possible error message and do not try to see your blog at this point! You will probably get a message about file not found.)
c. Move all files except for index.php and .htaccess to the new folder (ie. blog).
d. Open the index.php file you left on your root directory and edit as per step #2 above.
e. Log in to your blog as per step #4 above. That’s it!
No related posts.



