# How to check for headers

**URL:** <https://www.ruby-forum.com/t/how-to-check-for-headers/222211>\
**Category:** NGINX\
**Created:** [August 17, 2012, 12:23pm UTC](https://www.ruby-forum.com/t/how-to-check-for-headers/222211 "2012-08-17T12:23:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [August 17, 2012, 12:23pm UTC](https://www.ruby-forum.com/t/how-to-check-for-headers/222211/1 "2012-08-17T12:23:39Z")

</div>

Hello,

How would you check for sth like HTTP:Accept-Language? and in general  
all  
headers? if it is equal to some value, empty or etc. Apache would allow  
this  
to be checked in a notation similar to the following inside a  
mod\_rewrite  
config:

%{HTTP:Accept-Language}

Is there a similar variable to be used in nginx config?

Posted at Nginx Forum:

> **[how to check for headers](https://forum.nginx.org/read.php?2,229839,229839#msg-229839)**
>
> Hello, How would you check for sth like HTTP:Accept-Language? and in general all headers? if it is equal to some value, empty or etc. Apache would allow this to be checked in a notation similar to the following inside a mod\_rewrite config:...

---

<div class="post-metadata">

**Author:** ![amonmitch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c57346/32.png) [@amonmitch](https://www.ruby-forum.com/u/amonmitch)\
**Post date:** [August 17, 2012, 3:47pm UTC](https://www.ruby-forum.com/t/how-to-check-for-headers/222211/2 "2012-08-17T15:47:37Z")

</div>

On Fri, Aug 17, 2012 at 06:23:04AM -0400, amonmitch wrote:

Hi there,

> How would you check for sth like HTTP:Accept-Language? and in general all  
> headers? if it is equal to some value, empty or etc. Apache would allow this  
> to be checked in a notation similar to the following inside a mod\_rewrite  
> config:
> 
> %{HTTP:Accept-Language}
> 
> Is there a similar variable to be used in nginx config?

variables are at

> **[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#variables)**
>
> This directive appeared in version 1.11.8.

“map” is at [Module ngx\_http\_map\_module](http://nginx.org/r/map)

“if” is at [Module ngx\_http\_rewrite\_module](http://nginx.org/r/if)

Be aware of when you shouldn’t use “if” inside “location”, such as is  
written at [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/IfIsEvil)

Depending on what exactly you want to do, frequently “map” can be used  
instead of “if”.

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
