Rewrite with regex

Artur nginx at netdirect.fr
Mon Apr 12 13:01:12 UTC 2021


Le 12/04/2021 à 14:46, Francis Daly a écrit :
>
> Does 
>
>   rewrite "^/([a-z][-a-z]{0,30}[a-z])$" ...
>
> do what you want in most cases?

No, because it allows these cases I don't want :

- a-----b
- a---b---c---d

By the way, the regex I sent before don't work correctly.
It should be (still testing for errors...) :

rewrite "^/([a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*)$" /index.php?short_name=$1 last;

-- 

Best regards,
Artur



More information about the nginx mailing list