Why does your site get messed up when you turn on SEF (Search Engine Friendly URLs)?
Usually this has something to do with your host's settings. One solution that commonly works is to enter a value for the
$live_site variable in the configuration.php file found in the root directory of your Joomla site files. The value of the variable must be manually edited.
Typically, it would look like:
var $live_site = 'http://example.com';
But if you access your website in a folder, it would be like this:
var $live_site = 'http://example.com/joomla';
Unfortunately, this does not always work correctly. Setting it to just your folder may help:
var $live_site = '/joomla';
Sometimes the value (especially when determined by automatic installers other than that of Joomla!) can be present, but simply wrong. To enable the automatic base finding algorithm, empty it completely:
var $live_site = '';