Search code examples
joomlasubdirectory

Install Joomla in a subdirectory


As some of you may know, Wordpress has an options in settings to allow site installation in a subdirectory, while having the site URL be the main domain. It was something like "Site url" and "Wordpress url". I'm looking for something like this in Joomla. I know there is no inbuilt option for it, but I'd rather not have to move all the files if possible. And please, explain it to me like to a five year old, just in case :)


Solution

  • To move the whole joomla installation to a subfolder on the server (http://example.com/subdir), but still access it from the root (http://example.com) I did the following:

    • Move your whole installation to the subdir-folder
    • In configuration.php, set $live_site = "http://example.com";
    • Also change the tmp and log-folders in configuration.php
    • Add a .htaccess-file to the root-folder:

    (The code is modified from this excellent answer)

    RewriteEngine on
    RewriteCond %{THE_REQUEST} subdir/
    RewriteRule ^subdir/(.*) http://example.com/$1 [R=301,L]
    RewriteCond %{REQUEST_URI} !subdir/
    RewriteRule ^(.*)$ /subdir/$1 [L]
    

    Modify the default joomla .htaccess-file, now in the /subdir-folder, to include a RewriteBase:

    RewriteBase /subdir/
    

    After these modifications it seems everything works the way it should.