URI pattern baffling problem

Gregory ga at w00tw00t.ch
Mon Feb 7 17:43:29 MSK 2011


I am trying to work out a regular expression. What I am looking for is to
redirect any request that does not match a specific URI pattern.

The exact pattern is “documents/{VAR1}/pages/{VAR2}/items/{VAR3}” where
{VAR1} /{VAR2} /{VAR3} is a random chain of 36 characters made of A-Z, a-z,
0-9 and – (hyphen). Text is not case sensitive and the position of hyphens
is fixed. Would be great if I could also work trailing double-slash.

So far what I have generated is:

if ($request_uri !~*
"^documents/([a-z0-9\-]{36})pages/([a-z0-9\-]{36})items/([a-z0-9\-]{36})$" )
   rewrite ^ http://www.google.com/ permanent;

Regular expression is not really my cup of tea, so any hint is most welcome!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20110207/3aa0cf2c/attachment.html>

More information about the nginx mailing list