I
I
Ilya2018-12-10 12:28:32
htaccess
Ilya, 2018-12-10 12:28:32

HTACCESS redirect with saving/copying parameters on opencart 1.5?

Friends, how to make a redirect to OPENCART 1.5 from one address to another with full copying of arguments. The request comes from 1 address, but the parameters are different each time, and it is these parameters that must be automatically transferred each time to a new address.
old-link.ru/page?utm=utm1
old-link.ru/page?utm=utm2
old-link.ru/page?utm=utm3
new-link.ru?utm=currentUtm
_
RewriteCond %{QUERY_STRING} ^_route_=page.*
RewriteRule ^(.*)$ new-link.ru? [R=301,L,QSA]
It turns out: new-link.ru?&^_route_page&utm=utm1
And it is necessary: ​​new-link.ru?utm=utm1
He substituted my label, but opencart cannot get rid of the ROUTER label.
Can you please tell me if it works or what I did wrong? Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Taran, 2018-12-10
@shambler81

%{QUERY_STRING} - is not part of the url and stands out in a separate way

RewriteCond %{QUERY_STRING} (^|&)utm=(.+)($|&)
RewriteRule ^page\.php$ /new-link.ru\?utm=%2 [L,R=301]

%2 is the second group from RewriteCond the second group from RewriteRule $2
(.+)- 1 or more characters

D
dodo512, 2018-12-10
@dodo512

RewriteRule ^page$ http://new-link.ru/page [R=301,L]

The main thing is to put the rules for the redirect at the very beginning so that they work earlier than the rule for the CNC Then there will be no extra tails with _route_ RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question