# Nginx Dynamic Rewriting

**URL:** <https://www.ruby-forum.com/t/nginx-dynamic-rewriting/208325>\
**Category:** NGINX\
**Created:** [June 15, 2011, 11:15am UTC](https://www.ruby-forum.com/t/nginx-dynamic-rewriting/208325 "2011-06-15T11:15:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [June 15, 2011, 11:15am UTC](https://www.ruby-forum.com/t/nginx-dynamic-rewriting/208325/1 "2011-06-15T11:15:38Z")

</div>

Hello there,

is there a way to do dynamic rewriting something like this:

[http://localhost/param1/param2/param3/key4/value4/key5/value5/key6/value6](http://localhost/param1/param2/param3/key4/value4/key5/value5/key6/value6)  
and so on.

key value pairs can differ in wording and count.

i want to rewrite this to something like  
index.php?p1=$1&p2=$2&p3=$3&(loop)$4=$5 …

Thx.

---

<div class="post-metadata">

**Author:** ![Alexander\_Over](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bc79bd/32.png) [@Alexander\_Over](https://www.ruby-forum.com/u/Alexander_Over)\
**Post date:** [June 15, 2011, 11:25am UTC](https://www.ruby-forum.com/t/nginx-dynamic-rewriting/208325/2 "2011-06-15T11:25:32Z")

</div>

On Wed, Jun 15, 2011 at 4:14 PM, Alexander Over  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hello there,
> 
> is there a way to do dynamic rewriting something like this:
> 
> [http://localhost/param1/param2/param3/key4/value4/key5/value5/key6/value6](http://localhost/param1/param2/param3/key4/value4/key5/value5/key6/value6) and so  
> on.
> 
> key value pairs can differ in wording and count.
> 
> i want to rewrite this to something like index.php?p1=$1&p2=$2&p3=$3&(loop)$4=$5  
> …

yes, it’s called “parse in php”

make it pass p=param1/param2/param3/…  
the split by ‘/’ and assign each of them to correct variable
