# Is there any harm if the map directive in nginx is repeated for the same variable name?

**URL:** <https://www.ruby-forum.com/t/is-there-any-harm-if-the-map-directive-in-nginx-is-repeated-for-the-same-variable-name/228161>\
**Category:** NGINX\
**Created:** [April 11, 2013, 7:12pm UTC](https://www.ruby-forum.com/t/is-there-any-harm-if-the-map-directive-in-nginx-is-repeated-for-the-same-variable-name/228161 "2013-04-11T19:12:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayesh\_kapoor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e95f7d/32.png) [@jayesh\_kapoor](https://www.ruby-forum.com/u/jayesh_kapoor)\
**Post date:** [April 11, 2013, 7:12pm UTC](https://www.ruby-forum.com/t/is-there-any-harm-if-the-map-directive-in-nginx-is-repeated-for-the-same-variable-name/228161/1 "2013-04-11T19:12:09Z")

</div>

When I try it out, the definition that comes later seems to take effect.  
The  
question is, are there unintended consequences of doing this?

http {  
map $http\_host $a {  
hostnames;  
default 1;  
[example.com](http://example.com) 1;  
\*.example.com 2;  
}  
map $http\_host $a {  
hostnames;  
default 3;  
[example.com](http://example.com) 3;  
\*.example.com 4;  
}  
server {  
server\_name [example.com](http://example.com) \*.example.com  
location / {  
echo $a  
}  
}  
}  
Now with this configuration if I try:

curl [http://example.com](http://example.com)  
3  
curl [http://www.example.com](http://www.example.com)  
4  
Background: We are using this to provide an override for a map in an  
optional include file. So right after the map is defined, we have an  
include  
directive for \*\_override\_map.conf. If this file exists and provides an  
alternate definition for the same map, then thats what gets used instead  
of  
the original map definition.

Posted at Nginx Forum:

> **[Is there any harm if the map directive in nginx is repeated for the same...](https://forum.nginx.org/read.php?2,238301,238301#msg-238301)**
>
> When I try it out, the definition that comes later seems to take effect. The question is, are there unintended consequences of doing this? http { map $http\_host $a { hostnames; default 1; example.com 1; \*.example.c
