NthDegree
NthDegree

Reputation: 1341

URL Rewrite with encoded and "unencoded" special characters

I need to write redirects for a list of URLs and got some problems because they contain encoded as well as "unencoded" special characters.

Example:

http://example.com/lvl-+-1/écrire/gar%C3%A7ons/2/fr

As you can see, there is an é as well as encoded characters like %C3%A7 (for ç) in the same URL. How can I write a redirect for this?

Currently I'm trying the following, I already escaped the +characters with \:

RewriteRule ^lvl-\+-1/écrire/gar%C3%A7ons/2/fr https://www.example.com/Boîtes [NC,L,R=301,NE]

The new URLs contains special characters like î, therefore I set the NEtag. Unfortunately this isn't working, because I guess the characters are either not encoded at all or twice.

Is there a way to catch such URLs with with "unencoded" and encoded characters?

Upvotes: 1

Views: 365

Answers (1)

anubhava
anubhava

Reputation: 786071

To match % character use hex notation as \xMN.

This rule should work for you:

RewriteRule ^lvl-\+-1/écrire/gar\xC3\xA7ons/2/fr/?$ /Boîtes [NC,L,R=301,NE]

Upvotes: 1

Related Questions