Here is some documentation that you may find helpful (or confusing)
:
http://docs.joomla.org/Creating_a_System_Plugin_to_augment_JRouter
You don't need to tinker with .htaccess, or anything else. For my
extension the requirement was to add segments to the path so that it
looked like this:
http://mysite.com/XX-YYY/zz/example.html where
'example' is a view name and XX-YYY is a branch code that varies
with country and zz is a language code. The initial values of XX-YYY
and zz come either from geolocation or the url. It is perhaps easier
to understand the build rule - wherever you have a JRoute call in
your code:
JRoute::_('index.php?option=com_myextension&view=myview')
the build rule gets called. In my case it looke like this:
public function buildRule (&$router, &$uri)
{
if ($uri->getVar('option') == 'com_sciops') {
$input = new JInput($_COOKIE);
$branch_code = $input->get('branch_code', 'AA-SCI',
'string');
if ($branch_code != 'AA-SCI') {
$language_code = $input->get('language_code',
'en', 'string');
$uri->setPath($uri->getPath().'/'.$branch_code.'/'.$language_code.'/');
}
}
return;
}
So in the output page the links have XX-YYY/zz in the path (in the
example above AA-SCI is a default that is left out). If you follow
execution with the debugger there is one call for each link in the
output page. We keep the XX-YYY and zz values in cookies.
On input (one call per page load), to parse a url we need to turn
the XX-YYY/zz values back into parameters and remove them from the
path. This is my code to do that:
public function parseRule (&$router, &$uri) {
$vars = array();
$path = $uri->getPath();
if (preg_match('/[A-Z]{2}[-]{1}[A-Z]{2,3}\/[a-z]{2}/i',
$path) > 0) {
$parts = explode('/', $path);
$vars['url_branch'] = array_shift($parts);
$vars['url_language'] = array_shift($parts);
$uri->setPath(implode('/' , $parts));
} else if (preg_match('/[a-z]{2}\//', $path) > 0) {
$parts = explode('/', $path);
$vars['url_branch'] = 'AA-SCI';
$vars['url_language'] = array_shift($parts);
$uri->setPath(implode('/' , $parts));
}
return $vars;
}
so url_branch and url_language get returned in the vars array for
use elsewhere in the program. They end up in the Request so you can
access them with JFactory::getApplication()->input->get();
I hope this gives some extra insight.
Cliff