I came across the problem of how to rewrite (not redirect) users to a subdirectory while trying to install Joomla 1.5 in a subdirectory. The problem came when I wanted to hide the subdirectory. Instead of www.yoursite.com/subdir I wanted the users to just see www.yoursite.com. To do this, you must update the .htaccess files in the root directory with the following code:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# This section must come first!
# Add trailing slash if path does not contain a period or end with a slash
RewriteCond %{REQUEST_URI} !(\.|/$)
RewriteRule (.*) http://www.yoursite.com/$1/ [R=301,L]
#Change http://yoursite.com to http://www.yoursite.com (Optional)
RewriteCond %{HTTP_HOST} ^yoursite.com$
RewriteRule ^/?(.*)$ http://www.yoursite.com/$1 [R=301,L]
#Rewrites http://www.yoursite.com/subdir to http://www.yoursite.com/
RewriteCond %{REQUEST_URI} !^/subdir
RewriteRule ^(.*)$ subdir/$1 [L]Replace yoursite with the name of your website
Replace subdir with the name of your sub directory
For Joomla 1.5 users, place the .htaccess in the root directory of your website and change the following:
Change
# RewriteBase /
To
RewriteBase /
# Add trailing slash if path does not contain a period or end with a slash
RewriteCond %{REQUEST_URI} !(\.|/$)
RewriteRule (.*) http://www.yoursite.com/$1/ [R=301,L]
#Change http://yoursite.com to http://www.yoursite.com (Optional)
RewriteCond %{HTTP_HOST} ^yoursite.com$
RewriteRule ^/?(.*)$ http://www.yoursite.com/$1 [R=301,L]
#Rewrites http://www.yoursite.com/subdir to http://www.yoursite.com/
RewriteCond %{REQUEST_URI} !^/subdir
RewriteRule ^(.*)$ subdir/$1 [L]
Replace yoursite with the name of your website & subdir with the joomla directory
Also, change the configuration.php file.
Change
var $live_site = '';
To
var $live_site = 'http://www.yoursite.com/';Replace yoursite with the name of your website
Most of the .htaccess information came from these sites: .htaccess tips and tricks & non www redirect