# RewriteCond %{REQUEST\_URI} how to in nginx?

**URL:** <https://www.ruby-forum.com/t/rewritecond-request-uri-how-to-in-nginx/153865>\
**Category:** NGINX\
**Created:** [November 21, 2008, 11:55pm UTC](https://www.ruby-forum.com/t/rewritecond-request-uri-how-to-in-nginx/153865 "2008-11-21T23:55:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsimone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jsimone](https://www.ruby-forum.com/u/jsimone)\
**Post date:** [November 21, 2008, 11:55pm UTC](https://www.ruby-forum.com/t/rewritecond-request-uri-how-to-in-nginx/153865/1 "2008-11-21T23:55:45Z")

</div>

Sorry if this is a dumb question, but a newb to nginx rewrites, been  
trying to convert ALOT of websites over to nginx.

Though this one:

RewriteCond %{REQUEST\_URI} !(index.php|.css) [NC]

How would this translate to nginx?

Probably doesn’t matter?

Joe

---

<div class="post-metadata">

**Author:** ![jsimone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jsimone](https://www.ruby-forum.com/u/jsimone)\
**Post date:** [November 22, 2008, 2:21am UTC](https://www.ruby-forum.com/t/rewritecond-request-uri-how-to-in-nginx/153865/2 "2008-11-22T02:21:30Z")

</div>

That is not a rewrite rule, it is a rewrite condition. The rule is the  
first RewriteRule after the condition. Without the rule and all the  
conditions that apply to it, you won’t be able to convert it.

---

<div class="post-metadata">

**Author:** ![jsimone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jsimone](https://www.ruby-forum.com/u/jsimone)\
**Post date:** [November 22, 2008, 9:46am UTC](https://www.ruby-forum.com/t/rewritecond-request-uri-how-to-in-nginx/153865/3 "2008-11-22T09:46:55Z")

</div>

On Fri, Nov 21, 2008 at 04:48:30PM -0600, Joe S. wrote:

> Sorry if this is a dumb question, but a newb to nginx rewrites, been  
> trying to convert ALOT of websites over to nginx.
> 
> Though this one:
> 
> RewriteCond %{REQUEST\_URI} !(index.php|.css) [NC]
> 
> How would this translate to nginx?
> 
> Probably doesn’t matter?

You should inverse RewriteCond logic (making it clear to human):

location / {  
# !/(index.php|.css)  
…  
}

location ~ /index.php$ {  
…  
}

location ~ .css$ {  
…  
}
