V
V
vimbatu2021-12-29 15:34:23
PHP
vimbatu, 2021-12-29 15:34:23

How to write a regular expression for urlrewrite.php in Bitrix?

Good afternoon.

Please help me write a regular expression for url substitution using urlrewrite.php. The option with setting via .htaccess in this case is not suitable for SEO reasons.

The essence of the task is that there is a set of urls that a filter creates on the site, of the form:

/filter/tsvet-chernyy/available-yes/model-iphone_13-or-iphone_xs_max-or-iphone_12_pro/obem_pamyati-256_gb
and so there can be many additions depending on selected filters. The slash is followed by the name of the property (/model) followed by a dash and then listing the selected values ​​through -or-.

For technical reasons, this dash had to be replaced with =, that is, now the filter creates addresses like:

/filter/tsvet=chernyy/available=yes/model=iphone_13=or=iphone_xs_max=or=iphone_12_pro/obem_pamyati=256_gb

The problem is that the previous versions of addresses with a dash are indexed by search engines, and you need to make a 301 redirect to new addresses so that nothing is lost from the search.

How to write a correct regular expression so that, if the address contains a property name with a dash (any) or lists the property values ​​through -or- (any number), it will change them to the same with equal instead of a dash? You can't just change a dash to equal, because there may be other dashes in the address, for example, in the name or value of a property, or in additional GET parameters.

Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question