0

I am trying to write a rule in .htaccess to rewrite search requests containing Korean characters to a 404 page.

RewriteEngine On
RewriteCond %{QUERY_STRING} [\x{ac00}-\x{d7a3}]
RewriteRule ^(.*)$ /404.html [R=404,L]

When testing I get the message that the reqexp failed to execute.

When testing the same regex with preg_match in php it works.

if (preg_match('/[\x{ac00}-\x{d7a3}]/u', $string)) {
    echo "URL contains korean charachters";
}

Any advice?

was
  • 1
  • 1
  • mod_rewrite is not using PHP's regex "flavor"; I think it is more akin to python's version. Try https://stackoverflow.com/a/3836052/1427878 – CBroe Mar 01 '23 at 14:59
  • Thank you. I followed the tip and got the following regex to work in Pyton, but it still does not work in mod_rewrite [\uac00-\ud7a3] – was Mar 02 '23 at 21:38

0 Answers0