# Can anyone convert this mod rewrite rule

**URL:** <https://www.ruby-forum.com/t/can-anyone-convert-this-mod-rewrite-rule/205343>\
**Category:** NGINX\
**Created:** [April 4, 2011, 8:00pm UTC](https://www.ruby-forum.com/t/can-anyone-convert-this-mod-rewrite-rule/205343 "2011-04-04T20:00:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [April 4, 2011, 8:00pm UTC](https://www.ruby-forum.com/t/can-anyone-convert-this-mod-rewrite-rule/205343/1 "2011-04-04T20:00:23Z")

</div>

# 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

Posted at Nginx Forum:

> **[can anyone convert this mod rewrite rule](https://forum.nginx.org/read.php?2,188294,188294#msg-188294)**
>
> \# 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\] Rewri

---

<div class="post-metadata">

**Author:** ![onel0ve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c4cdca/32.png) [@onel0ve](https://www.ruby-forum.com/u/onel0ve)\
**Post date:** [April 4, 2011, 9:15pm UTC](https://www.ruby-forum.com/t/can-anyone-convert-this-mod-rewrite-rule/205343/2 "2011-04-04T21:15:08Z")

</div>

On Mon, Apr 04, 2011 at 02:00:06PM -0400, onel0ve wrote:

> 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 S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![onel0ve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c4cdca/32.png) [@onel0ve](https://www.ruby-forum.com/u/onel0ve)\
**Post date:** [April 4, 2011, 10:04pm UTC](https://www.ruby-forum.com/t/can-anyone-convert-this-mod-rewrite-rule/205343/3 "2011-04-04T22:04:38Z")

</div>

rewrite ^thumb-(._).jpg$ /thumb.php?id=$1 last;  
rewrite ^image-(._).jpg$ /image.php?id=$1 last;

etc.

Posted at Nginx Forum:

> **[Re: can anyone convert this mod rewrite rule](https://forum.nginx.org/read.php?2,188294,188330#msg-188330)**
>
> \# 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\] Rewri

---

<div class="post-metadata">

**Author:** ![onel0ve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c4cdca/32.png) [@onel0ve](https://www.ruby-forum.com/u/onel0ve)\
**Post date:** [April 4, 2011, 10:06pm UTC](https://www.ruby-forum.com/t/can-anyone-convert-this-mod-rewrite-rule/205343/4 "2011-04-04T22:06:30Z")

</div>

EDIT:  
i forgot to add / in front

rewrite ^/thumb-(._).jpg$ /thumb.php?id=$1 last;  
rewrite ^/image-(._).jpg$ /image.php?id=$1 last;

Posted at Nginx Forum:

> **[Re: can anyone convert this mod rewrite rule](https://forum.nginx.org/read.php?2,188294,188333#msg-188333)**
>
> \# 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\] Rewri
