I put in clean urls but I now have an issue that will cause duplicate content issues.

Here is what is happening:

If I go Here:
http://www.dieselgeneratorsmiami.com...lter-kits.html

And click on the pagination links at the bottom, everything works fine until I hit the previous link. It then creates this link with the /0/ directory. Link here:

http://www.dieselgeneratorsmiami.com...lter-kits.html

How can I make it just go back to the original url?

Here is the pagination function:

PHP Code:
function buildNavigation($pageNum_Recordset1,$totalPages_Recordset1,$prev_Recordset1,$next_Recordset1,$separator=" | ",$max_links=10$show_page=true)
{
                GLOBAL 
$maxRows_lista_productos,$totalRows_lista_productos;
    
$pagesArray ""$firstArray ""$lastArray "";
    if(
$max_links<2)$max_links=2;
    if(
$pageNum_Recordset1<=$totalPages_Recordset1 && $pageNum_Recordset1>=0)
    {
        if (
$pageNum_Recordset1 ceil($max_links/2))
        {
            
$fgp $pageNum_Recordset1 ceil($max_links/2) > $pageNum_Recordset1 ceil($max_links/2) : 1;
            
$egp $pageNum_Recordset1 ceil($max_links/2);
            if (
$egp >= $totalPages_Recordset1)
            {
                
$egp $totalPages_Recordset1+1;
                
$fgp $totalPages_Recordset1 - ($max_links-1) > $totalPages_Recordset1  - ($max_links-1) : 1;
            }
        }
        else {
            
$fgp 0;
            
$egp $totalPages_Recordset1 >= $max_links $max_links $totalPages_Recordset1+1;
        }
        if(
$totalPages_Recordset1 >= 1) {
            
#    ------------------------
            #    Searching for $_GET vars
            #    ------------------------
            
$_get_vars '';            
            if(!empty(
$_GET) || !empty($HTTP_GET_VARS)){
                
$_GET = empty($_GET) ? $HTTP_GET_VARS $_GET;
                foreach (
$_GET as $_get_name => $_get_value) {
                    if (
$_get_name != "pageNum_lista_productos") {
                        
$_get_vars .= "/$_get_value";
                    }
                }
            }
            
$successivo $pageNum_Recordset1+1;
            
$precedente $pageNum_Recordset1-1;
            
$firstArray = ($pageNum_Recordset1 0) ? "<a href=\"http://www.dieselgeneratorsmiami.com/powergeneralpages/$precedente$_get_vars.html\">$prev_Recordset1</a>" :  "$prev_Recordset1";
            
# ----------------------
            # page numbers
            # ----------------------
            
for($a $fgp+1$a <= $egp$a++){
                
$theNext $a-1;
                if(
$show_page)
                {
                    
$textLink $a;
                } else {
                    
$min_l = (($a-1)*$maxRows_lista_productos) + 1;
                    
$max_l = ($a*$maxRows_lista_productos >= $totalRows_lista_productos) ? $totalRows_lista_productos : ($a*$maxRows_lista_productos);
                    
$textLink "$min_l - $max_l";
                }
                
$_ss_k floor($theNext/26);
                if (
$theNext != $pageNum_Recordset1)
                {
                    
$pagesArray .= "<a href=\"http://www.dieselgeneratorsmiami.com/powergeneralpages/$theNext$_get_vars.html\">";
                    
$pagesArray .= "$textLink</a>" . ($theNext $egp-$separator "");
                } else {
                    
$pagesArray .= "$textLink"  . ($theNext $egp-$separator "");
                }
            }
            
$theNext $pageNum_Recordset1+1;
            
$offset_end $totalPages_Recordset1;
            
$lastArray = ($pageNum_Recordset1 $totalPages_Recordset1) ? "<a href=\"http://www.dieselgeneratorsmiami.com/powergeneralpages/$successivo$_get_vars.html\">$next_Recordset1</a>" "$next_Recordset1";
        }
    }
    return array(
$firstArray,$pagesArray,$lastArray);