M
M
Mesuti2020-08-27 13:30:45
htaccess
Mesuti, 2020-08-27 13:30:45

How to replace part of the address?

Hey!
How to replace part of url with 301?

site.ru?param1=text1¶m2=text2
to
site.ru?param2=text2

Moreover, the param1 part to be replaced can be both at the end and at the beginning of the get request, and it can also be different text1

I try unsuccessfully to do so. Works only on the main page of the site, does not work on internal pages

RewriteCond %{QUERY_STRING} ^(.*)param1=text1+(.*)$ [NC]
RewriteRule ^(.*)$ /$1?%1%2 [R=301,L]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2020-08-27
@Mesuti

RewriteCond %{QUERY_STRING} ^(|.*?&)param1=[^&]*&?(.*)
RewriteRule .* /$0?%1%2 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question