You should avoid matching with *
and use +
instead. What more, your rules are "greedy" and that's why to much is matched. You should replace (.*)
with ([^/]+)
which will match only strings to /
character and at least one character.
When user enters adress: website.com/uleiuri/category-name/brand-name/
using your rules, cat
variable is filled with category-name/brand-name
and brand
is an empty string, and that's probably why all the products are returned.
Your rules should look like those:
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
# single product page
RewriteRule ^uleiuri/([^/]+)/([^/]+)/([^/]+)-([0-9]+)/?$ produs.php?id=$4 [L]
# oils page by category and brand
RewriteRule ^uleiuri/([^/]+)/([^/]+)/?$ uleiuri.php?cat=$1&brand=$2 [L]
# oils page by category
RewriteRule ^uleiuri/([^/]+)/?$ uleiuri.php?cat=$1 [L]
</IfModule>