# Rewrite N|next flag in apache

**URL:** <https://www.ruby-forum.com/t/rewrite-n-next-flag-in-apache/215474>\
**Category:** NGINX\
**Created:** [January 5, 2012, 11:18am UTC](https://www.ruby-forum.com/t/rewrite-n-next-flag-in-apache/215474 "2012-01-05T11:18:11Z")\
**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:** [January 5, 2012, 11:18am UTC](https://www.ruby-forum.com/t/rewrite-n-next-flag-in-apache/215474/1 "2012-01-05T11:18:11Z")

</div>

Hi everyone,

I’m writing here because i have rewrite problems on Nginx. First of all  
i will explain to you what result i’m expecting.  
For example i have this URL :

[http://www.mydomain.com/api/redirect/var1/value1/var2/value2/varX/valueX/?varX=valueX&](http://www.mydomain.com/api/redirect/var1/value1/var2/value2/varX/valueX/?varX=valueX&)…

after rewrite i would like to get :

[Web Hosting, Domain Name Registration - MyDomain.com](http://www.mydomain.com/?var1=value1&var2=value2&varX=valueX&varX=valueX)…

So i get it works on apache with :

RewriteRule  
^(api/redirect/[^/]+/[^/]+/[^/]+)/([^/]+)/([^/]+)([^?]\*)  
$1$4/?&$2=$3 [QSA,N]  
RewriteRule ^api/redirect/[^/]+/[^/]+/([^/]+)  
index.php?service=Redirect&hash=$1 [QSA,L]

And now i would like to have the same on nginx, but i think nginx  
doesn’t handle something like apache’s N flag. Then it’s my nginx  
rewrite rules, it work once because it doesn’t re-execute rewrite while  
it’s possible.

rewrite ^/(api/redirect/[^/]+/[^/]+/[^/]+)/([^/]+)/([^/]+)([^?]\*)  
/$1$4/?&$2=$3;  
rewrite ^/api/redirect/[^/]+/[^/]+/([^/]+)  
/public/index.php?service=Redirect&func=Redirect&hash=$1 last;

Do someone have a solution for this please ? I will apreciate a lot.  
thanks you.

Best regards,

Posted at Nginx Forum:

> **[rewrite N|next flag in apache](https://forum.nginx.org/read.php?2,220833,220833#msg-220833)**
>
> Hi everyone, I'm writing here because i have rewrite problems on Nginx. First of all i will explain to you what result i'm expecting. For example i have this URL :...

---

<div class="post-metadata">

**Author:** ![layneuks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/77aa72/32.png) [@layneuks](https://www.ruby-forum.com/u/layneuks)\
**Post date:** [January 5, 2012, 4:23pm UTC](https://www.ruby-forum.com/t/rewrite-n-next-flag-in-apache/215474/2 "2012-01-05T16:23:03Z")

</div>

No one ? I need a solution… ;'(

Posted at Nginx Forum:

> **[Re: rewrite N|next flag in apache](https://forum.nginx.org/read.php?2,220833,220845#msg-220845)**
>
> Hi everyone, I'm writing here because i have rewrite problems on Nginx. First of all i will explain to you what result i'm expecting. For example i have this URL :...
