19-Jun-2011

Moving your Joomla Installation

Move your Joomla website to its own folder on your web server. This is a good idea if you host more than one site from your hosting account.I decided to move my Joomla installation from the /public_html to a subdirectory. This would keep separate my client's sites from my own and make management easier.

Create or Modify .htaccess

In order to also set up the main domain to use a subdirectory on the hosting account set up a redirect in the .htaccess file in the public_html folder so that the server knows that any request for your main domain will be redirected to a subdirectory on public_html.

To setup the rewrite/redirect, edit the ~/public_html/.htaccess file. Insert the following code block and make modifications as noted in the (#) comments.

# Bluehost.com # .htaccess main domain to subdirectory redirect # Copy and paste the following code into the .htaccess file # in the public_html folder of your hosting account # make the changes to the file according to the instructions. # Do not change this line. RewriteEngine on # Change yourdomain.com to be your main domain. RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$ # Change 'subdirectory' to be the directory you will use for your main domain. RewriteCond %{REQUEST_URI} !^/subdirectory/ # Don't change this line. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Change 'subdirectory' to be the directory you will use for your main domain. RewriteRule ^(.*)$ /subdirectory/$1 # Change yourdomain.com to be your main domain again. # Change 'subdirectory' to be the directory you will use for your main domain # followed by / then the main file for your site, index.php, index.html, etc. RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$ RewriteRule ^(/)?$ subdirectory/index.php [L]

Visitors to your Web site will not be able to tell that your main domain is using a subdirectory, they will still see the Web site address as http://www.yourdomain.com/page.html.

Note: Using this method will set up a 302 redirect. For more information please look at the following links.

Domain name change of address. http://www.google.com/support/webmasters/83106
Moving website address. http://www.google.com/support/webmasters

Note: To set the main domain to a subfolder as a 301 redirect do no use this method. Bluehost suggests following the advice that google provides regarding 301 redirects.

(from https://my.bluehost.com/cgi/help/347?step=347 , viewed June-2011)

Modifying Joomla's configuration.php file

Changing the .htaccess file worked fine but I had a problem with the url. You could browse to www.rinet.com.au OK but after clicking a few links the url would change to www.rinet.com.au/rinet. It seemed to work but some of the images using relative links were not working. It was somewhat annoying and after a search on Google I found the answer.

We must tell Joomla not to include the subfolder in the links it creates within its pages.

We want http://domain.com/index.php not http://domain.com/joomla1/index.php.

We do this by editing the configuration.php file in the Joomla folder, and changing the $live_site variable as follows
(NOTE: change domain.com to your actual domain):

Add/edit the following in configuration.php:

var $live_site = 'http://www.domain.com';

Leave a Reply

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram