/ / .htaccess nie działa z umlautami i (POST) identyfikatorami URI - .htaccess

.htaccess nie działa z umlautami i (POST) identyfikatorami URI - .htaccess

Potrzebuję twojej pomocy z plikiem .htaccess (te pliki są jednym z moich ulubionych zadań :-)). Mój obecny .htaccess wygląda tak:

# Start rewrite engine
RewriteEngine on

# Check if no file, link or directory is requested
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-d

# Do not rewrite install and admin
RewriteRule ^admin$ admin/ [R=301,L]
RewriteRule ^install$ install/ [R=301,L]

# Pass the requested path to index.php
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)$ index.php?p=$1/$2 [QSA]
RewriteRule ^([a-zA-Z0-9_]+)$ index.php?p=$1 [QSA]

# Define error document for all errors
ErrorDocument 401 index.php?p=error
ErrorDocument 403 index.php?p=error
ErrorDocument 404 index.php?p=error
ErrorDocument 410 index.php?p=error

Główna funkcjonalność działa poprawnie, ale mam następujący problem:

Jeśli wygeneruję błąd (na przykład dostęp /unknownFolder), strona błędu jest ładowana zgodnie z oczekiwaniami. Ale jeśli mam Ululaut (szczególnie ä, ü, ö, ß) w moim URI, będzie tylko wyjście index.php?p=error. Jakieś wyjaśnienie lub rozwiązanie tego niedorzecznego problemu?

Odpowiedzi:

2 dla odpowiedzi № 1

Twój regex nie pasuje do tych znaków: ([a-zA-Z0-9_]+). Spróbuj zmienić te grupy na ([^/.]+) więc pasuje do wszystkiego oprócz ukośników i kropek:

# Pass the requested path to index.php
RewriteRule ^([^/.]+)/([^/.]+)$ index.php?p=$1/$2 [QSA]
RewriteRule ^([^/.]+)$ index.php?p=$1 [QSA]

Prawdopodobnie dzieje się tak dlatego, że te umlatowe postacie nie pasują do tych reguł, nie są właściwie kierowane do index.php plik, a tym samym 404.