12

I have a joomla site and it is installed in a subfolder in my hosting account.

So now if I want to access my site I have to type www.mysite.com/joomla. I want to be able to access my site's homepage directly with my domain www.site.com.

How to do this ?

7 Answers 7

14

Here are the steps required to move a joomla site from subfolder to the root:

  1. Use a FTP client and connect to your hosting account via FTP, or use the File Manager that should be available in the Control Panel of your hosting account.
  2. Navigate to the folder where Joomla resides (root/joomla).
  3. Locate configuration.php file, download and open it with a text editor (not a word-processing software like ms word).
  4. You are looking for the following lines:

    var $live_site = '';
    var $log_path = '/home/username/public_html/joomla/logs';
    var $tmp_path = '/home/username/public_html/joomla/tmp';
    var $ftp_root = 'public_html/joomla';
    

    Change to:

    var $live_site = '';
    var $log_path = '/home/username/public_html/logs';
    var $tmp_path = '/home/username/public_html/tmp';
    var $ftp_root = 'public_html';
    

If the $live_site variable had a value:
e.g. $live_site = 'http://www.site.com/joomla';

then adjust like:
$live_site = 'http://www.site.com';

  1. Save configuration.php and upload it back to its previous location.
  2. Check for a file named .htaccess. If it's available, edit this as well. You are looking for the following line:

    RewriteBase /joomla Change to: RewriteBase /

*instead of joomla, expect to see your actual's subfolder's name, where joomla resides.

  1. Navigate back to your Root folder. If there are files and folders of an older site, it's best advised to create a new folder, name it something like "old-site", and put all of its files in this folder.
  2. Now all you need to do is to move the files/folders of the Joomla installation to the root folder.
  3. After the move is complete, login to the administrator and clean Joomla's cache. Go to System -> Clear Cache and clean up the cached files.
  4. Check the front-end of your site.
  5. If everything works fine - remember to delete the files of the old site if you don't need them anymore.
5

Just an additional bit here. Most people will not need to do this as they don't ever touch the robots.txt file, however if you have something like the following:

User-agent: *
Disallow: /joomla/administrator/
Disallow: /joomla/bin/
Disallow: /joomla/cache/
Disallow: /joomla/cli/
Disallow: /joomla/components/
Disallow: /joomla/includes/
Disallow: /joomla/installation/
Disallow: /joomla/language/
Disallow: /joomla/layouts/
Disallow: /joomla/libraries/
Disallow: /joomla/logs/
Disallow: /joomla/modules/
Disallow: /joomla/plugins/
Disallow: /joomla/tmp/

Then you need to remove the /joomla prefix at the beginning of each path.

0
5

If you have shell access to your host, it also makes sense to store the Joomla install outside of the webroot and symlink it in. This way, you can source control the installation or easily switch between multiple staging/production versions.

Using this with subdomains also makes the testing process for new versions much easier.

2
  • Could you elaborate more on this? Maybe a new question&answer post on how to achieve this, it might be interesting for many users.
    – johanpw
    Commented Nov 14, 2014 at 0:41
  • SE didn't seem to like my potential titles for the question, so I'll have to work on that, but I elaborated on this process in another answer here: joomla.stackexchange.com/q/4145/58 Commented Nov 14, 2014 at 19:11
3

Best would be to change the assigned root folder of your site on your web hosting seetings. I do this so I can build new versions of my site and save/keep the old versions alive; all I have to do is change my domain's "Document Root" to the new folder every time I release a new version. Avoid redirecting your site, Google's search algorythm doesn't like it.

2

I wonder why no one suggested using Akeeba Backup component and Akeeba Kickstart script. For some users, it might be easier way of doing the same as FFrewin suggested. Akeeba does all that automatically.

Both of them are free (in basic version, you don't need pro). You can download them directly on AkeebaBackup.com/download.

The required steps are:

  1. Install Akeeba Backup
  2. Set Akeeba Backup up, there's a one-click auto setup right after you open the component in your Joomla Administration
  3. Backup your site via Akeeba Backup
  4. Download your backup (.jpa file)
  5. Upload your backup to the new location on your FTP (no matter if it's a different host or just a different folder, you can move your site anywhere, even localhost)
  6. Unpack Akeeba Kickstart and upload the kickstart.php file to the same location where you uploaded the .jpa file
  7. In your browser, direct to http://newlocation.xy/kickstart.php
  8. Akeeba Kickstart will open, choose direct method
  9. Go through to whole process and fill required fields (just like a new Joomla installation)
    • Database connection settings (server, name, password) - if you want to keep the same database as you already have, use a different table prefix
    • Website settings - set new live URL including http://, that's most important. Additionally, you can also change the superadmin password and setup new FTP accounts)
    • When everything is done, click "remove installation folder"
  10. That's it, if the new site works, you can remove your site in the previous location and the old database tables (they should have a different prefix or be in a separate database).

Before deleting your previous installation, make sure your new one really works. Your backup file may be corrupted from downloading or whatever and you might not be able to install the backup.

I'm also aware that this looks like a bit more complicated way, but it's not, I believe it's easier and usually faster - copying thousands of files (whole Joomla) from your FTP location to your computer and uploading them to your new FTP location takes hours. With Akeeba, you can be up and running in less than an hour (depending on the size of your Joomla website).

6
  • No one suggested Akeeba, because the question is about moving the installation from a subdirectory at the root of the same hosting.
    – FFrewin
    Commented Nov 14, 2014 at 23:04
  • Still, you can use Akeeba for that. It's just a different option.
    – TeeJay
    Commented Nov 15, 2014 at 10:53
  • 1
    Of course it's an option, but what you are describing in your answer is like going from Paris to London through Tokyo. All this procedure is just unnecessary. You mentioned that you can be up and running in less than hour, when the actual procedure should be a couple of minutes and there is no need to mess with the database at all.
    – FFrewin
    Commented Nov 15, 2014 at 12:38
  • I actually prefer using Akeeba for situations such as this myself, as the Akeeba installer script is specifically written to adjust things like tmp and cache paths and so forth in the configuration, and you have the added benefit of a full backup. An hour is a far far longer process than it actually takes if you use the Cpanel file manager to move the files on the server itself. You take a backup which takes a bit less than 2 minutes for most sites. File move is 30 seconds, deploy to root about a minute or 2. And no checking of individual file paths to correct.
    – Toni Marie
    Commented Nov 15, 2014 at 16:05
  • This is a possible solution, however I think Akeeba Backup is overkill for such as easy process that does not require any extensions. Using Akeeba means you need to create a backup, download it, set kickstart up and basically install Joomla again (so to speak). rather a long process when you can simply move folder using your hosting File Manager and tweak a couple of lines in the config
    – Lodder
    Commented Nov 22, 2014 at 18:32
2

If you want to redirect your localhost to some subfolder instead of root folder like

/var/www/subfolder

Then you need to do this configuration at server. open the file at following path:

/etc/apache2/sites-enabled/000-default.conf

then you need to change the root path of the folder at follows:

ServerAdmin webmaster@localhost
DocumentRoot /var/www/subfolder

Now if you will run the localhost then it will open the file of subfolder.

1
  • This answer seems to be useful for Linux users with Apache server on specific distributions like Ubuntu. Furthermore if the root only has the subfolder, it's better to move the subfolder to the root.
    – Farahmand
    Commented Nov 15, 2014 at 10:38
0

Akeeba Backup works well. If you have a previous joomla site already installed in your root, be sure to delete the joomla folders in the root before you move the new site to the root or you may have stray incompatible templates, etc. left over from that previous version.

I would also recommend going into your cpanel->myPHP admin and exporting your database for another layer of backup. The Akeeba backup file includes your database, so this is just a redundancy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.