L
L
lexstile2019-06-09 14:00:07
htaccess
lexstile, 2019-06-09 14:00:07

How to correctly write rewriterule for Cyrillic?

Everything works in Latin:

RewriteRule ^text/([a-zA-Z]+)/?$ /app/text/detail.php?t=$1

I tried to substitute а-яёА-ЯЁ - it did not help, more precisely - it works only with the first letter after the slash (for example, / text / а).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-06-09
@lexstile

\p{Cyrillic} https://www.php.net/manual/ru/regexp.reference.uni...
And if you need not only Cyrillic, then \p{L}.
If you use [а-яёА-ЯЁ], then the file must be saved in UTF-8 without BOM.
Another option.

RewriteRule ^text/((?:\xd0[\x81\x90-\xbf]|\xd1[\x80-\x91])+)/?$ /app/text/detail.php?t=$1 [L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question