I’ve spent quite some time getting my private Joomla! site to work the way I want with urls.
A short good step-by-step has for me proven very hard to find.
Several guides and post have been close, but still failed at the end for various reasons, so I’ll explain briefly what I wanted to achieve and then exactly what does the trick.
I have my private domain, http://www.example.com hosted by One.com.
I’m using Joomla! for the main site, and then various other stuff in subdomains, like forum.example.com for my forum.
However I want to have my current active Joomla! installation in a subdirectory on the server but not show in the url of the browser.
I also like to have only one way of using the site, either with www or without.
So my setup expressed as example is this:

Domain: www.example.com
Webhost: One.com
File path on server: /joomla/

Default links like http://www.example.com/joomla/index.php?option=com_contact&view=contact&id=1&Itemid=13&lang=en it should show as http://example.com/en/contact instead.

I’ll not go into reasoning why, this is the way I want to have it, and if this is how you want it too, please keep on reading, you are close…

These are the steps you need to do:

    1. Edit your webroot .htaccess
    2. Rename and then edit your default Joomla! htaccess.txt
    3. Configure Joomla! to use SEF and Apache mod_rewrite

Ok, now to the task of getting that htaccess correct, checking out the mod_rewrite documentation on the Apache site you get the following encouraging quotes to digest:

“The great thing about mod_rewrite is it gives you all the configurability and flexibility of Sendmail. The downside to mod_rewrite is that it gives you all the configurability and flexibility of Sendmail.”
— Brian Behlendorf
Apache Group
“Despite the tons of examples and docs, mod_rewrite is voodoo. Damned cool voodoo, but still voodoo.”
— Brian Moore


Instead of figuring out how to to this, I of course use my favorite search engine to get a post that has already done it, but no, I didn’t find a single post that gave me the answer, some were close as I’ve already mentioned.
The thing is, it is depending upon your servers configuration, which can vary in so many ways, and by having your site on a cheap Webhost like I have, you have very scarce information. So, post that did the trick for some people, did not work for me on One.com.
So I ended up actually having to learn something about it…

Enough talking, now to business:

1. Edit your .htaccess in your webroot directory on the server. Note:www.example.com should be replaced by your domain and that /joomla with the directory you have your live joomla in.

# Make sure mod_rewrite is on, this is ok even if it is already on higher up in the hierarchy.
RewriteEngine On

#Match all www and do a permanent redirect from www.example.com to example.com
RewriteCond %{HTTP_HOST} ^www.(.*) [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,NC,L]

#Ok, now get rid of that joomla directory in the resulting url.
RewriteCond %{REQUEST_URI} !^/joomla/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /joomla/$1 [L] RewriteRule ^(/)?$ joomla/index.php [L]

2. Now edit your htaccess.txt in your root Joomla directory and when done, rename it to .htaccess

#Make sure this is commented and not active, otherwise nothing will work.
#Options +FollowSymLinks

#Uncomment all RewriteCond and RewriteRule in this section
########## Begin – Joomla! core SEF Section

########## End – Joomla! core SEF Section

#Uncomment all RewriteCond and RewriteRule in this section
########## Begin – Rewrite rules to block out some common exploits

########## End – Rewrite rules to block out some common exploits


3.Now, edit your configuration.php in your Joomla root directory.

$live_site ='http://example.com'
$sef = '1'
$sef_rewrite = '1'
$sef_suffix = '0'

Alternatively using the admin backend.
Site –> Global Configuration –> Site –> SEO Settings



Still, you have to edit manually the configuration.php for the live_site, this was added in Joomla! 1.5.2 to enable Joomla to reside in a subdirectory and generate urls with a different root.

Well, that’s it, now it should work like a charm 🙂