can anyone convert this mod rewrite rule

Igor Sysoev igor at sysoev.ru
Mon Apr 4 23:14:34 MSD 2011


On Mon, Apr 04, 2011 at 02:00:06PM -0400, onel0ve wrote:
> # BEGIN DPIOptions
> 
> RewriteEngine On
> RewriteRule ^thumb-(.*)\.jpg$ thumb.php?id=$1 [L]
> RewriteRule ^image-(.*)\.jpg$ image.php?id=$1 [L]
> RewriteRule ^image-(.*)\.gif$ image.php?id=$1&gif [L]
> RewriteRule ^share-(.*)\.html$ share.php?id=$1 [L]
> RewriteRule ^gallery-(.*)-(.*)-(.*)\.html$ gallery.php?id=$2&page=$3
> [L]
> RewriteRule ^gallery-(.*)-(.*)\.html$ gallery.php?id=$2 [L]
> RewriteRule ^archive-(.*)\.html$ archive.php?page=$1 [L]
> RewriteRule ^galleries-(.*)\.html$ archive.php?page=$1 [L]
> RewriteRule ^content-(.*)\.html$ content.php?$1 [L]
> RewriteRule ^profile-(.*)\.html$ profile.php?id=$1 [L]
> RewriteRule ^images-(.*)\.html$ images.php?date=$1 [L]
> 
> # END DPIOptions
> 
> please convert this for nginx

Here is example of scaleable configuration:

location /thumb- {
    location ~ ^/thumb-(.*)\.jpg$ {
        fastcgi_pass   ...
        fastcgi_param  SCRIPT_FILENAME  /path/to/thumb.php;
        fastcgi_param  QUERY_STRING     id=$1;
    }
}

location /image- {
    location ~ ^/image-(.*)\.jpg$ {
        fastcgi_pass   ...
        fastcgi_param  SCRIPT_FILENAME  /path/to/image.php;
        fastcgi_param  QUERY_STRING     id=$1;
    }

    location ~ ^/image-(.*)\.gif$ {
        fastcgi_pass   ...
        fastcgi_param  SCRIPT_FILENAME  /path/to/image.php;
        fastcgi_param  QUERY_STRING     id=$1&gif;
    }
}

etc.


-- 
Igor Sysoev
http://sysoev.ru/en/



More information about the nginx mailing list