Rewrite translation apache to nginx

Цэвээндорж tseveendorj at gmail.com
Fri Nov 25 05:19:41 UTC 2011


Hello,

I have always difficulty with rewrite translating apache to nginx.

<IfModule mod_rewrite.c>
         RewriteEngine On
         #
         #  Full path to your site
         #
         RewriteBase /
         # Rename Photo Names
         RewriteRule 
^file/pic/photo/([0-9]+)/([0-9]+)/([A-Za-z0-9]{32}+)\-(.*?)([_0-9]*?)\.(.*)$     
file/pic/photo/$1/$2/$3$5.$6
         #
         #  Rules
         #
         RewriteCond %{REQUEST_FILENAME} !-f
         RewriteCond %{REQUEST_FILENAME} !-d
         RewriteRule ^(.*) index.php?do=/$1
         # Image Access Protection
         RewriteRule ^file/pic/photo/(.*)\.(.*)$  
static/image.php?file=$1&ext=$2
</IfModule>


It is my translation

location / {
rewrite 
^file/pic/photo/([0-9]+)/([0-9]+)/([A-Za-z0-9]{32}+)\-(.*?)([_0-9]*?)\.(.*)$       
file/pic/photo/$1/$2/$3$5.$6 break;

if (!-f $request_filename ) {
break;
}

if (!-d $request_filename) {
break;
}

rewrite ^(.*)$ index.php?do=/$1
}


How to convert it properly.

Thanks
Tseveen.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20111125/dc232826/attachment.html>


More information about the nginx mailing list