2011年2月7日星期一

Re: URI pattern baffling problem

Firstly you are missing slashes after each var/regex

Sent from my iPod

On 08/02/2011, at 1:43 AM, Gregory <ga@w00tw00t.ch> wrote:

Hi,

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!

Gregory

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

没有评论:

发表评论