A
A
Alexander2021-11-20 15:04:02
htaccess
Alexander, 2021-11-20 15:04:02

How to make a redirect by removing the parameters?

Hello!
Tell me how to make a 301 first redirect from a page in .htaccess?
домен.рф/каталог/?first=11088&second=56926
to the page
домен.рф/каталог/11088/56926/

Numbers are obviously not known, part of the url is in Cyrillic.

For some reason, google examples don't help.
As far as I understand it should be something like this:

RewriteRule ^/каталог/?first=(.*)&second=(.*)$ /каталог/%1/%2/ [R=301,L]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2021-11-20
@IIvanich

RewriteCond %{QUERY_STRING} ^first=(\d+)&second=(\d+)
RewriteRule ^каталог/$ /$0%1/%2/? [R=301,L]

Put the redirect above the rest of the rules.
Save the .htaccess file in UTF-8 encoding without BOM.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question