B
B
Big_person2016-04-13 14:18:43
Regular Expressions
Big_person, 2016-04-13 14:18:43

How to properly compose regex in htaccess for CNC directory filters?

We have a string in the url of the following form:
catalog/category/subrcategory1/subcatecory.../filter/parametr1_znachene/parametr2_znachene/parametr..._znachene/brand_name.html
How to pass the values ​​of all parameters to the executable script?
You need something like this:

RewriteRule ^catalog/(?:.*/)?([^/]+)/filter/(?:.*/)?([^/]+)/brand_([^/]+)$		index.php?module=Storefront&category=$1&filter=$2&brand=$3 [L,QSA]

The current construction works, but only the last parameter_value is passed to the filter parameter, but everything must be passed, so that later in the php script, using any separator and a regular expression, you can get all the parameters and their values.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2016-04-13
@shambler81

RewriteCond %{REQUEST_URI} (групап1)(групап1)(групап1)(групап1)$
RewriteRule ^(.*) http://site.ru/index.php\?module=....\?=%1\?=%2\?=%3   [NC,L,QSA]

Screen the main questions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question