1

I've got this setup:

RewriteRule ^brands$ brands/ [R=301,L]
RewriteRule ^brands/$ /brands.php
RewriteRule ^brands/([A-ZÆØÅæøåa-z0-9-]+)-([0-9]+)/$ index.php?manufacturers_name=$1&manufacturers_id=$2 [L,QSA]
RewriteRule ^brands/([0-9]+)$ index.php?manufacturers_id=$1 [L]

How would I fix it so there's alway a trailing slash on this - Those specific urls?

xxx.com/brands/brand-id

So if I either went to xxx.com/brands/brand-id OR xxx.com/brands/brand-id/ - It'll work as having a trailing slash?

Dennis A
  • 61
  • 7
  • Possible duplicate of [Htaccess: add/remove trailing slash from URL](https://stackoverflow.com/questions/21417263/htaccess-add-remove-trailing-slash-from-url) – Syntax Error Jan 18 '18 at 11:39
  • I only need it for those specific rules though, not the rest of the site. – Dennis A Jan 18 '18 at 11:40

1 Answers1

0

Replace your Rule with this

 RewriteRule ^brands/([0-9]+)/?$ index.php?manufacturers_id=$1 [L]

/? means that the / is optional in uri. Your rule will match both uri strings ending with or without a traling slash.

And to add the traling slash to specific uris,put the following before your existing rules

RewriteRule ^brands/[0-9]+$ %{REQUEST_URI}/ [L,R]

This will redirect /brands/123 to /brands/123/ .

Amit Verma
  • 39,545
  • 18
  • 87
  • 107