<span style="font-family: trebuchet ms,sans-serif;">Hi,</span><br style="font-family: trebuchet ms,sans-serif;"><br style="font-family: trebuchet ms,sans-serif;"><span style="font-family: trebuchet ms,sans-serif;">I am trying to work out a regular expression.</span><span style="font-family: trebuchet ms,sans-serif;"> What I am looking for is to redirect any request that does not match a specific URI pattern.</span><br style="font-family: trebuchet ms,sans-serif;">

<br style="font-family: trebuchet ms,sans-serif;"><font style="font-family: trebuchet ms,sans-serif;" size="2">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.</font><br style="font-family: trebuchet ms,sans-serif;">

<br style="font-family: trebuchet ms,sans-serif;"><span style="font-family: trebuchet ms,sans-serif;">So far what I have generated is:</span><br style="font-family: trebuchet ms,sans-serif;"><br style="font-family: trebuchet ms,sans-serif;">

<span style="font-family: courier new,monospace;">if ($request_uri !~* &quot;^documents/([a-z0-9\-]{36})pages/([a-z0-9\-]{36})items/([a-z0-9\-]{36})$&quot; ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">   rewrite ^ <a href="http://www.google.com/">http://www.google.com/</a> permanent;</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">} </span><br style="font-family: courier new,monospace;"><br style="font-family: trebuchet ms,sans-serif;"><span style="font-family: trebuchet ms,sans-serif;">Regular expression is not really my cup of tea, so any hint is most welcome!</span><br style="font-family: trebuchet ms,sans-serif;">

<br style="font-family: trebuchet ms,sans-serif;"><span style="font-family: trebuchet ms,sans-serif;">Gregory</span><br style="font-family: trebuchet ms,sans-serif;"><br style="font-family: trebuchet ms,sans-serif;">