4

I am trying to redirect requests from a umlaut domain to another domain.

My following code works with ANY other domain, but not umlaut:

<IfModule mod_rewrite.c>
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} ^(www\.)?frankfurter-flöhe\.de/$ [NC]
  RewriteRule ^ http://kinderkultur-frankfurt.de/frankfurter-floehe-theaterprogramm.html [R=301,L]
</IfModule>

However, when I call the umlaut domain and then copy it from Google Chrome's address bar, I get this:

http://xn--frankfurter-flhe-zwb.de/

Although, if I use that obfuscated domain in my htaccess file instead of the "real" umlaut domain, it doesn't work either.

Does anybody have an idea how to match that domain?

MrWhite
  • 12,647
  • 4
  • 29
  • 41
  • 1
    "that obfuscated domain" is in [Punycode](https://en.wikipedia.org/wiki/Punycode) and is how internationalised domains are stored in DNS. – MrWhite Mar 08 '16 at 09:03

3 Answers3

1

Try using the NE flag, to prevent mod_rewrite from encoding the URL. For more information about NE: http://httpd.apache.org/docs/current/rewrite/flags.html#flag_ne

<IfModule mod_rewrite.c>
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} ^(www\.)?frankfurter-flöhe\.de/$ [NC,NE]
  RewriteRule ^ http://kinderkultur-frankfurt.de/frankfurter-floehe-theaterprogramm.html [R=301,L]
</IfModule>

If this doesn't work, try to use the HEX equivalent of umlaut, as suggested in: https://stackoverflow.com/questions/11107375/umlauts-in-htaccess-redirects

Kao
  • 197
  • 1
  • 13
  • I tried this already (as mentioned above) and it doesn't work. –  Oct 04 '12 at 10:09
  • I updated my answer to use the NE flag instead. – Kao Oct 04 '12 at 10:31
  • The NE flag results in an error 500 –  Oct 04 '12 at 13:10
  • Did you add the space after NC, NE? That might cause the 500 error. I removed it from the answer. It might also be [NC] [NE] - Not really sure. I will run some tests later if you don't get it working. – Kao Oct 04 '12 at 13:22
  • The error appears with and without the space, as well as when only the NE flag is used. –  Oct 04 '12 at 13:30
  • And is it safe to assume that you've tried with: frankfurter-flh%C3%A4he\.de/$ without the NE tag? – Kao Oct 05 '12 at 08:44
  • The `NE` flag only applies to the `RewriteRule` directive in order to prevent the substitution (ie. the _target URL_) from being escaped when sending back a response. It does not apply to the `RewriteCond` directive (which is only concerned with pattern matching), hence the 500 error. – MrWhite Mar 08 '16 at 09:12
0

The UTF-8 URL with Umlaut needs to be converted into ACE encoding (ASCII Compatible Encoding).

You can use the following online tool to convert an international domain with Umlauts.

www.frankfurter-flöhe.de becomes xn--frankfurter-flhe-zwb.de and this is what needs to be used in the htaccess redirect.

T. Junghans
  • 103
  • 4
0

Did you try with :

RewriteEngine On
RewriteCond %{HTTP_HOST} ^frankfurter-flöhe.de$ [OR]
RewriteCond %{HTTP_HOST} ^www.frankfurter-flöhe.de$
RewriteRule (.*)$ http://kinderkultur-frankfurt.de/frankfurter-floehe-theaterprogramm.html [R=301,L]
  • 1
    You simply split up my condition into two conditions. My condition works perfectly well with other domain names but not with the umlaut domain. Splitting it up makes no difference. –  Oct 04 '12 at 10:09
  • Yes but I want to check if when splitting your conditions, it solves the problem, because redirection on frankfurter-flöhe.de works, but not www.frankfurter-flöhe.de redirection –  Oct 04 '12 at 10:18
  • Nope, it does not work. –  Oct 04 '12 at 13:15