S
S
Spindog2021-03-26 15:06:46
htaccess
Spindog, 2021-03-26 15:06:46

How to set up a redirect with a url that contains special characters?

A url of the form https://site.ru/section/%20target=/ appeared on the site, it needs to be redirected to https://site.ru/section/
A simple redirect does not work, since the string contains special characters. I tried to escape with a backslash, https://site.ru/section/\%20target\=/ doesn't work either. Oddly enough, there is very little information on the Internet about this, has anyone really come across it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2021-03-26
@dodo512

At the beginning of .htaccess add:

RewriteCond %{THE_REQUEST} " /section/%20"
RewriteRule ^ https://site.ru/section/ [R=301,L]

Or
RewriteRule ^section/\s https://site.ru/section/ [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question