Welcome! Log In Create A New Profile

Advanced

Re: Rewrite with regex

Artur
April 12, 2021 08:22AM
Le 12/04/2021 à 12:19, Francis Daly a écrit :
> 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
No, + means 1 or more.
> and it's probably simplest to do that as two separate "rewrite" rules.

In fact it works as is. The only problem is that there is no simple way
to check the total string length.
But having several rewrite rules may be also a good idea.

Is it possible to check the size of $uri ?

--

Best regards,
Artur

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Rewrite with regex

Artur April 12, 2021 05:32AM

Re: Rewrite with regex

Artur April 12, 2021 06:04AM

Re: Rewrite with regex

Francis Daly April 12, 2021 06:20AM

Re: Rewrite with regex

Artur April 12, 2021 08:22AM

Re: Rewrite with regex

Francis Daly April 12, 2021 08:48AM

Re: Rewrite with regex

Artur April 12, 2021 09:02AM

Re: Rewrite with regex

Francis Daly April 12, 2021 05:14PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 247
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready