Anything set to $segments
will appear in the url. So this $segments[] = $query['view'];
adds the view to the url. Since your parser automatically sets the view, still unset the view in the build function, but don't push it into $segments
:
function BahaediniBuildRoute(&$query)
{
$segments = array();
if(isset($query['view']))
{
unset( $query['view'] );
}
...
Naturally, you may have to adjust your parser, since now the number of segments will be different, so you will need different index values.