B
B
bichukov2021-12-15 18:02:16
1C-Bitrix
bichukov, 2021-12-15 18:02:16

How to redirect in one step?

There is a site to which double /
https://tehikhouse.by/catalog//reaktor_rb//

to solve the problem, I wrote the following lines in HTACCESS
RewriteCond %{REQUEST_URI} ^(.*?)\/{2,}(.*? )$
RewriteRule . %1/%2 [L,R=301]
RewriteCond %{THE_REQUEST} //
RewriteRule .* /$0 [R=301,L]

They are gone, but the solution is not quite correct because multiple redirects are performed, i.e. the redirect is performed several times , from one page to another, to one or more.

How to do it in one step?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2021-12-15
@bichukov

RewriteCond %{REQUEST_URI} ^(.*?)\/{2,}(.*?)$
RewriteRule . %1/%2 [L,R=301]
RewriteCond %{THE_REQUEST} //
RewriteRule .* /$0 [R=301,L]

From this leave only
RewriteCond %{THE_REQUEST} //
RewriteRule .* /$0 [R=301,L]

In case the GET parameters turn out to be //necessary to limit the search so that the redirect does not loop.
RewriteCond %{THE_REQUEST} ^[^?]+//
RewriteRule .* /$0 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question