# Rewrites

**URL:** <https://www.ruby-forum.com/t/rewrites/212673>\
**Category:** NGINX\
**Created:** [October 10, 2011, 1:44pm UTC](https://www.ruby-forum.com/t/rewrites/212673 "2011-10-10T13:44:12Z")\
**Posts on this page:** 3\
**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:** [October 10, 2011, 1:44pm UTC](https://www.ruby-forum.com/t/rewrites/212673/1 "2011-10-10T13:44:12Z")

</div>

Hi,

i need to translate this htaccess to nginx:

RewriteCond %{QUERY\_STRING} !^/?url  
RewriteCond %{QUERY\_STRING} !^/?auto  
RewriteRule ^(.\*)$ /?url=$1 [L]

is this the right solution?

if ($args !~ “^/?url”){  
set $rule\_0 1$rule\_0;  
}  
if ($args !~ “^/?auto”){  
set $rule\_0 2$rule\_0;  
}  
if ($rule\_0 = “21”){  
rewrite ^/(.\*)$ /?url=$1 last;  
}

cheers,

juergen

---

<div class="post-metadata">

**Author:** ![gromminger](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a4c791/32.png) [@gromminger](https://www.ruby-forum.com/u/gromminger)\
**Post date:** [October 10, 2011, 8:22pm UTC](https://www.ruby-forum.com/t/rewrites/212673/2 "2011-10-10T20:22:53Z")

</div>

On Mon, Oct 10, 2011 at 01:43:34PM +0200, Juergen G. wrote:

> is this the right solution?
> 
> if ($args !~ “^/?url”){  
> set $rule\_0 1$rule\_0;  
> }  
> if ($args !~ “^/?auto”){  
> set $rule\_0 2$rule\_0;  
> }  
> if ($rule\_0 = “21”){  
> rewrite ^/(.\*)$ /?url=$1 last;  
> }

Are you sure, that your requests are somethig like “/some/page?/?auto=1”  
?  
Could you explain what you want to get ?

–  
Igor S.

---

<div class="post-metadata">

**Author:** ![gromminger](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a4c791/32.png) [@gromminger](https://www.ruby-forum.com/u/gromminger)\
**Post date:** [October 10, 2011, 10:18pm UTC](https://www.ruby-forum.com/t/rewrites/212673/3 "2011-10-10T22:18:22Z")

</div>

if ($args !~ ^(url|auto)) {  
rewrite ^(.\*)$ http://$server\_name/?url=$uri$is\_args$args break;  
}

Andrejs

Posted at Nginx Forum:

> **[Re: rewrites](https://forum.nginx.org/read.php?2,216459,216481#msg-216481)**
>
> Hi, i need to translate this htaccess to nginx: RewriteCond %{QUERY\_STRING} !^/?url RewriteCond %{QUERY\_STRING} !^/?auto RewriteRule ^(.\*)$ /?url=$1 \[L\] is this the right solution? if ($args !~ "^/?url"){
