I would need help with a url redirect which includes Umlaut in my htaccess

Hi, this might be a bit off topic, but perhaps s.o. could help me. I need to redirect a URL to a new URL in the htaccess.

Old URL:
https://adler-glasreinigung.de/gewerbekunden%20für%20glasreinigung%20büro%20und%20schaufenster%2048268%20greven.html

New URL:
https://adler-glasreinigung.de/glasreinigung-gewerbe/

For the spaces inside the URL it is sufficient to use " " and the redirect works fine, e. g.
Redirect 301 "/adler solar und photovoltaik reinigung.html" /solar-und-photovoltaikreinigung/index.html

But I am at loss with these Umlauts . Who invented them anyway? Oh, might have been my folks :slight_smile:

The Server is Apache, apart from this I have not much information.

So if anyone has a clue I am grateful.

Thanks for reading!
Jan

I’m not sure if it’ll work but you could try replacing them with the ascii/html codes: https://www.lsa.umich.edu/german/hmr/schreiben/umlaute/umlaute_ASCII_html.html

So büro becomes büro

Here’s a full table of the ascii/html codes: https://www.ascii.cl/htmlcodes.htm

2 Likes

Thank you, this did not work. I am using a direct inside the old page html now, based on:
http://insider.zone/tools/client-side-url-redirect-generator/

But I would prefer this to be in the htacess with a 301 so that google can use it properly.

Thanks again,
Jan

You just want to redirect a certain directory? Then I would try this (you have to convert umlauts and special characters in the path into ASC II):

Options +FollowSymLinks
RewriteEngine On
Redirect 301 /adler-glasreinigung.de/gewerbekunden%2520f%C3%BCr%2520glasreinigung%2520b%C3%BCro%2520und%2520schaufenster%2048268%20greven.html https://adler-glasreinigung.de/glasreinigung-gewerbe/

Not sure if that works, but try it

When we phoned in the morning I didn’t understand what you want to do. I understood there was a blank character in the domain name and could not imagine how that worked before

Did you get anything work on this?
I think the problem you’re having has to di with both “blanks” and “diacriticals” (umlaut) in the Regex part of the redirect. Regex(regular expressions) and htaccess files (Apache) both predate UTF encoding. You can get around the spaces with the quotes, but that doesn’t seem to work with the umlaut. You can try to match the hex or decimal values but with Unicode characters all having multiple variations you would have to have an exact match, and you could use the " trick with the spaces. The UTF-8 code hex values won’t work inside quotes, they would be interpreted as their literal values.

To make it much simpler you could forget about an exact match. So in this example, I’m assuming (might be wrong since I don’t speak the language the site is in) that the page that is being redirected is the only page on the site that ends with greven.html? If that is the case please give this a try:

RewriteEngine On
rewriteRule greven.html$ https://adler-glasreinigung.de/glasreinigung-gewerbe/ [L,R=302]

If this works as soon as you’re done testing and are sure it works then change the r=302 to r=301 to make a permanent redirect.
Please keep us posted.

2 Likes

Great idea! I Test it tomorrow (it is night here) and report back. Thanks!

Hi, this works. Great. I mean - this works great! But - isn‘t there always a but - I have two old URLs which end with greven. One ends with “und greven”. The other one with “48268 greven”. How could the rule be adapted?

Thanks again,
Jan

Not sure if I understand what you’re asking, the one you gave above ended with:
48268 greven.html
Now are you saying that in addition you have a URL that ends with just 48268 greven (without the html) that needs redirection?
Or
The url und greven is actually ending with:
und greven.html
And is getting redirected by the rule I gave above as well?
Either one should be able to get addressed, just need to know what exactly you’re asking for. Some sample full url’s might help.

The url und greven is actually ending with:
und greven.html
And is getting redirected by the rule I gave above as well?

Yes - this is the case. Not dramatic but I wonder if I can distinguish them by adjusting the rule.

Not sure if this will work but you can give it a try:

RewriteEngine On
rewriteRule \Q48268 \Egreven.html$ https://adler-glasreinigung.de/glasreinigung-gewerbe/ [L,R=302]

(I’m a little rusty on regex)

No, in this case I get a server error. But it’s fine working as it is.

Thanks again,
Jan

If your happy with what you got that’s okay, but I’m curious as to why you get a server error. I tested it on the handy htaccess tester and it seems to work ok. Of course, the tester is just a tester and is different than a real server. Usually, I’ve seen “server errors” on htaccess file because of an improper file format (not plan text), but you can get them for other reasons.

Me too. I think always when a\ is used, a server error appears…