K
K
kichik912014-10-06 06:02:12
Apache HTTP Server
kichik91, 2014-10-06 06:02:12

How to setup redirect with mod_rewrite with symbols =, ' ' etc.?

Good afternoon!
There is a link:
http ://somesite. ru /category/view/NDgyMA%3D%3D/fDExfA%3D%3D
You need to set up a redirect to:
https ://somesite. com /category/view/NDgyMA%3D%3D/fDExfA%3D%3D
With these settings in htaccess:

RewriteEngine On
RewriteRule /(.*) https://somesite.com/$1 [B,R=permanent,L]

I get this link:
https://somesite.com/category %252 fview %252f NDgyMA%253d%253d %252f fDExfA%253d%253d
and I need this:
https://somesite.com/category/view / NDgyMA%253D %253D / fDExfA%253D%253D
That is, even / is escaped, this causes a problem, this link contains = signs that must be converted to safe characters, but slashes are not

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kichik91, 2014-10-06
@kichik91

Answer, config:

Options +FollowSymLinks

RewriteEngine On
RewriteCond %{THE_REQUEST} \ (/[^\ ]*)\  [NC]
RewriteRule /(.*) https://somesite.com/%1 [NE,R=301,L]

Attempts to use other variables or flags failed, a second encoding or decoding occurred, getting from THE_REQUEST made it possible to insert a reference "as is" and using the NE flag prevented the string from being decoded.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question