Languages: English • Français • WordPress Its Own Directory 日本語 Polski • Русский • Português do Brasil • (Add your language)
Some people want their WordPress URL to coincide with their website'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 it into a subdirectory, but have your website served from the website root.
As of Version 3.5, Multisite users may use all of the functionality listed below. If you are running a version of WordPress older than 3.5, please update before installing a Multisite WordPress install on a subdirectory.
Note to theme/plugin developers: this will not separate your code from WordPress. Themes and plugins will still reside under wp-content folder.
Caveat: Do this at your own risk. For most site owners, it is not recommended to put WordPress in a different directory unless you have a very good reason, and are an experienced and highly skilled WordPress developer, as this can cause issues with a lot of plugins.
Let's say you've installed wordpress at `example.com`. Now you have two different methods to move wordpress installations into subdirectory: 1) Without change of site URL (remains `example.com`) 2) With change in site URL (it will redirect to `example.com/subdirectory`)
1) After Installing the wordpress in root folder, move EVERYTHING from root folder into subdirectory.
2) Create a `.htaccess` file in root folder, and put this content inside (just change example.com and my_subdir):
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} ^(www.)?example.com$ RewriteCond %{REQUEST_URI} !^/my_subdir/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /my_subdir/$1 RewriteCond %{HTTP_HOST} ^(www.)?example.com$ RewriteRule ^(/)?$ my_subdir/index.php [L] </IfModule>
3.) Change the instances of "my_subdir" in lines 4, 7 and 9 to use the name of your subdirectory
4.) Change the instances of "example.com" to match your site's domain name.
5.) Save/upload the file
That's all :)
(p.s. If you've already installed WP in subdirectory, some steps might be already done automatically).
In some cases, some people like to install separate versions in a subdirectory (such as /2010, /2011, /latest and etc..), and want that website (by default) used the latest version, then Install WordPress in a subdirectory, such as /my_subdir
and in your root folder's .htaccess file add the following (just change the words as you need):
RewriteEngine On RewriteCond %{HTTP_HOST} ^(www.)?example.com$ RewriteRule ^(/)?$ my_subdir [L]
Now when users go to your root domain (example.com), it will automatically redirect to the subdirectory you specified.
Note: This code comes from Site 5's post here: How to Redirect Your Domain to a Subfolder Using .htaccess.
The following links explains how to change specific directories within WordPress: