How to Rewrite Joomla into a SubDirectory

When it comes to Rewriting Joomla for free. Here it can be adapted as needed for other site apps in web hosting.


There can be problems risen on how to rewrite users into a subdirectory while trying the installation of Joomla 1.5 into the subdirectory of web hosting. This problem is risen when one wants to hide the subidrectory. Instead of using www.yoursite.com/subdir here the users would like to see www.yoursite.com.

For doing this one must be able to update the .htaccess files which is in the root directory of web hosting with the following code as shown:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

This is the section which can come for free.
Here adding the trailing slash if the path is not containing for a period or its been ending with a slash

ewriteCond %{REQUEST_URI} !(\.|/$)
RewriteRule (.*) http://www.yoursite.com/$1/ [R=301,L]

#Now change the http://yoursite.com to http://www.yoursite.com

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]


Now you need to replace your site with the name of your original website

Now you need replace subdir with the name of your sub directory
For the users who are using Joomla 1.5, you need to place the .htaccess in the root directory of your own website and then you need to change the following:

Change
# RewriteBase /
To
RewriteBase /
# Now you need to add the trailing slash if the path is not containing a period or is ending with a slash
RewriteCond %{REQUEST_URI} !(\.|/$)
RewriteRule (.*) http://www.yoursite.com/$1/ [R=301,L]

#Now you need to 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]

Once you have performed this then you need to replace the name yoursite with the name of your personal website & then subdir it with the joomla directory

You also need to change the configuration.php file.

Change
var $live_site = ”;
To
var $live_site = ‘http://www.yoursite.com/’;

Here you need to replace yoursite with the name of your website.