title: How to use JRouter to rewrite controller and task URLs?
body: <p>I'm using Joomla 1.5 with <strong>router.php</strong> file to rewrite URLs of <strong>views</strong>. Here are contents of <strong>router.php</strong>:</p>
  
  <pre><code>&lt;?php
  function PvcCalcProBuildRoute( &amp;$query )
  {
    $segments = array();
    if(isset($query['view']))
    {
      $segments[] = $query['view'];
      unset( $query['view'] );
    }
    return $segments;
  }
  function PvcCalcProParseRoute( $segments )
  {
    $vars = array();
    switch($segments[0])
    {
      case 'cart':
      $vars['view'] = 'cart';
      break;
      case 'checkout':
      $vars['view'] = 'checkout';
      break;
      case 'login':
      $vars['view'] = 'login';
      break;
      case 'orders':
      $vars['view'] = 'orders';
      break;
      case 'offers':
      $vars['view'] = 'offers';
      break;
    }
    return $vars;
  }
  ?&gt;
  </code></pre>
  
  <p>I need to enable URL rewriting for <strong>controller</strong> and <strong>task</strong>. For example this line:</p>
  
  <pre><code>JRoute::_('index.php?option=com_pvccalcpro&amp;amp;task=helpers');
  </code></pre>
  
  <p>I want to convert to <strong>/component/pvccalcpro/helpers.js</strong></p>
  
  <p>And this line:</p>
  
  <pre><code>JRoute::_('index.php?option=com_pvccalcpro&amp;amp;controller=orders&amp;amp;task=js');
  </code></pre>
  
  <p>I want to convert to <strong>/component/pvccalcpro/orders.js</strong></p>
  
  <p>I tried to figure out how to accomplish that with official <a href="http://docs.joomla.org/Supporting_SEF_URLs_in_your_component" rel="nofollow">Joomla Routing Manual</a>, but after spending so many days it still didn't work out for me. Perhaps I'm missing something?</p>
  
  <p>Here are contents of my <strong>orders</strong> controller for example:</p>
  
  <pre><code>&lt;?php
  // no direct access
  defined('_JEXEC') or die();
  jimport('joomla.application.component.model');
  class PvcCalcProControllerOrders extends PvcCalcProController
  {
      function display()
      {
        parent::display();
      }
  
      function js()
      {
        $t=time()+31536000;
        $expires = gmdate('D, d M Y H:i:s \G\M\T',$t);
        header('Content-type: text/javascript; charset=utf-8');
        header('Vary: Accept-Encoding');
        header('Last-Modified: Tue, 27 Dec 2001 07:05:43 GMT');
        header('Expires: '.$expires);
        header('Cache-Control: public, max-age=31536000');
        require_once(JPATH_COMPONENT.DS.'assets/js/orders.js');
        die();
      }
  }
  ?&gt;
  </code></pre>