Rewrite with regex
Francis Daly
francis at daoine.org
Mon Apr 12 10:19:42 UTC 2021
On Mon, Apr 12, 2021 at 12:02:32PM +0200, Artur wrote:
Hi there,
> This seems to work :
>
> rewrite "^/((?:[a-zA-Z0-9]+(?:[-][a-zA-Z0-9])*)+)$"
> /index.php?short_name=$1 last;
>
> However, I suppose there is no way to check the size of $1 here.
So far, it looks like you want to allow either:
* 1 letter-or-number
or
* 1 letter-or-number, then 0-to-30 letter-or-number-or-hyphen, then
1 letter-or-number
and it's probably simplest to do that as two separate "rewrite" rules.
Good luck with it,
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list