ok, the htaccess is
RewriteRule ^shop/(.*)/(.*)/(.*)$ shop_product_details_s.php?perm=$3 [NC,L,QSA,T=application/x-httpd-php]
RewriteRule ^shop/(.*)/(.*)$ shop_product_results_s.php?perm=$2 [NC,L,QSA,T=application/x-httpd-php]
RewriteRule ^shop/(.*)$ shop_category_results_s.php?perm=$1 [NC,L,QSA,T=application/x-httpd-php]
an example of the on page link is shop/for-the-horse/bridles/product-7 which is being driven by the code shop/<?php echo($Categories->getColumnVal("parentpermalink")); ?>/<?php echo($Categories->getColumnVal("CatPermalink")); ?>/<?php echo($Categories->getColumnVal("ProdPermalink")); ?>