Forum

Thread tagged as: Question, Offtopic

.htaccess for friendly categories

I have a list and detail set of products at /products/index.php Each product has one or more categories allocated to it.

Using this htaccess rule I can clean up the ?cat= part when displaying products in a particular category.

RewriteRule ^products/([a-zA-Z0-9-/]+)$ /products/?cat=$1 [L]

Enabling me to view the list of products in a particular category at the url: /products/products/gifts-for-the-girls/

However, I'd really like to lose the extra /products/ from the category path and just have the url to be /products/gifts-for-the-girls/

How can I achieve this?

Thanks.

Simon Clay

Simon Clay 127 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I think that just comes down to how you write out the link in your template, doesn't it?

Simon Clay

Simon Clay 127 points

Sorry, you're right. It is just down to the link and how to filter:

perch_content_custom('Products', [
            'template' => '_product_listing.html',
            'category' => 'products/'.perch_get('cat'),
          ]);