Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache rewrite rules with Perl backslash sequences not working

I have one pretty simple rewrite rule working on Nginx:

rewrite (*UTF8)^/([\pL\pN\/-]*)$ /index.php?route=$1;

It uses Perl backslash sequences to match all unicode letters and numbers.

I tried to reproduce it on Apache:

RewriteRule ^([\pL\pN\/-]*)$ /index.php?route=$1 [QSA,L]

however it matches only slashes and dashes. Error log is clean.

like image 872
Infensus Avatar asked Dec 10 '25 19:12

Infensus


1 Answers

mod_rewrite doesn't support \p properties but you can use \w with B and NE flag that will send you rewritten URI unescaped to /index.php:

RewriteRule ^([\w/-]+)$ /index.php?route=$1 [QSA,L,B,NE]

PS: \w also includes underscore.

like image 158
anubhava Avatar answered Dec 12 '25 15:12

anubhava