Transparently redirect your root directory to a subdirectory

If you would like install something using the one-click manager, it wants you to use an empty directory. If you want to use the root of your web directory, then you have to delete everything on your domain. A better solution is to use a new directory for your installation (wordpress, joomla, etc) and then transparently redirect all request to that sub directory. So for example, any request for any file or folder at http://example.com would forward to http://example.com/cms, excluding files and folders that already exist. So, if someone requested http://example.com/blog it wouldn't forward to http://example.com/cms/blog unless the directory "blog" already existed in your domain's root directory..

Configuring mod_rewrite to transparently redirect requests
In order to do this you'll need to create an .htaccess file with the following content: Options -Indexes +SymLinksIfOwnerMatch RewriteEngine on RewriteBase / RewriteCond %{REQUEST_URI} !^/cms/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /cms/$1 [L]
 * 1) Don't apply to URLs that go to existing files or folders
 * 1) Rewrite all those to insert /folder

This .htaccess file above assumes the subdirectory to which you want to redirect all traffic is /cms/. If it is not you will need to change the two references to the cms directory. Save this .htaccess file in the root of your domain's directory (e.g. /home/YOUR_USERNAME/example.com/). If you need help creating and uploading the .htaccess file, please refer to the .htaccess page.

If you want to redirect independently if you have existing files or folders just create an .htaccess with the following content:

Options -Indexes +SymLinksIfOwnerMatch RewriteEngine on RewriteBase / RewriteCond %{REQUEST_URI} !^/cms/ RewriteCond %{HTTP_HOST} ^(www\.)?domain\. RewriteRule ^(.*)$ /cms/$1 [L]
 * 1) Rewrites all URLS [Replace "domain" with the actual domain, without the TLD (.com, .net, .biz, etc)]
 * 1) Rewrite all those to insert /folder

Redirecting in WordPress
This feature is actually built in to WordPress, and their official directions on their codex work well for Giving WP it's own Directory from a pre-existing subdirectory.

Configuring Joomla to be compatiable with the mod_rewrite technique

 * In Joomla 1.0 you will need to modify the $mosConfig_live_site variable in the configuration.php file located in your Joomla directory to equal your domain name (e.g. ).
 * In Joomla 1.5 you will need to modify the $live_site variable in the configuration.php file located in your Joomla directory to equal your domain name (e.g. ).

sh404SEF
sh404SEF will give a 404 error for every page when using the .htaccess method.

sh404SEF 404 Work Around
Create a index.php in the root of your domain (e.g. /home/YOUR_USERNAME/example.com/index.php) with the following code:



Note: You may need to change "cms" to the directory you used for your Joomla Installation.