full of … these

RewriteRules for special characters

Posted: November 18th, 2009 | Author: | Filed under: fun, howto, idiots, linux | Tags: , , , | No Comments »

Let’s say you have to write RewriteRules for special characters (East Asian Languages in this example, but, it should work for any other).

Link that you want to work: http://domain.tls/리눅스
Destination http://domain.tld/linux

First you must convert/encode (I used http://people.w3.org/rishida/scripts/uniview/conversion.php)
리눅스 is converted to %EB%A6%AC%EB%88%85%EC%8A%A4
You can get this from your access.log file of your server if you access it.
Now, you have to escape the % to match the regexp. Replace % with \x:

RewriteEngine On #add it in case it was not added above
ewriteCond %{HTTP_HOST} domain.tld
RewriteRule ^/\xEB\xA6\xAC\xEB\x88\x85\xEC\x8A\xA4$ http://http://domain.tld/linux

Restart or reload.
mod_rewrite should be loaded.
Debug: read /var/log/httpd/error.log and access.log (or corresponding error/access log file for the vhost you want the rule to be added.

Leave a Reply