Nginx Rewrite Apache?

António P. P. Almeida appa at perusio.net
Tue Apr 12 01:32:00 MSD 2011


On 11 Abr 2011 22h19 WEST, nginx-forum at nginx.us wrote:

> Hi
> I have problem with rewrite from apache
> RewriteEngine On 
>
> RewriteRule
> ^[A-Z]{3}[a-z]{2}[0-9]{4}[a-z]{3}[0-9]{4}[A-Z]{2}[a-z]{1}[0-9]{1}/(.+)$
> files/$1
>
> rewrite
> ^[A-Z]{3}[a-z]{2}[0-9]{4}[a-z]{3}[0-9]{4}[A-Z]{2}[a-z]{1}[0-9]{1}/(.+)$
> /files/$1 last; This rule dosent work...  Problem is { } On apache
> this work
> http://xx.xx.xx/QJNqq0821sxz7200DAp0/Si.s_sred.iowi.cze.part5.rar
> rewriting to to http://xx.xx.xx/files/Si.s_sred.iowi.cze.part5.rar
> but http://xx.xx.xx/dsadasdaddsads/Si.s_sred.iowi.cze.part5.rar
> musnt not work

From: http://wiki.nginx.org/NginxHttpRewriteModule#rewrite

      Note: for curly braces( { and } ), as they are used both in
      regexes and for block control, to avoid conflicts, regexes with
      curly braces are to be enclosed with double quotes (or single
      quotes). For example, to rewrite URLs like:

 
      /photos/123456 
      to:

 
      /path/to/photos/12/1234/123456.png 
      use the following (note the quotes enclosing the regex):

      rewrite  "/photos/([0-9] {2})([0-9] {2})([0-9] {2})" /path/to/photos/$1/$1$2/$1$2$3.png;

--- appa




More information about the nginx mailing list