# How to perform if condition for string with REGEX in nginx conf

**URL:** <https://www.ruby-forum.com/t/how-to-perform-if-condition-for-string-with-regex-in-nginx-conf/253116>\
**Category:** NGINX\
**Created:** [September 30, 2019, 8:45pm UTC](https://www.ruby-forum.com/t/how-to-perform-if-condition-for-string-with-regex-in-nginx-conf/253116 "2019-09-30T20:45:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![amey1809](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e274bd/32.png) [@amey1809](https://www.ruby-forum.com/u/amey1809)\
**Post date:** [September 30, 2019, 8:45pm UTC](https://www.ruby-forum.com/t/how-to-perform-if-condition-for-string-with-regex-in-nginx-conf/253116/1 "2019-09-30T20:45:20Z")

</div>

Hi,

I was trying to achieve for following url using nginx.

[https://localhost/xyz/d/\_0uzUTWZZw/message?orgId=1](https://localhost/xyz/d/_0uzUTWZZw/message?orgId=1)  
if such url requested contains string orgId then set some value to variable.

[https://localhost/xyz/d/\_0uzUTWZZw/message?orgId=1&var-id=2](https://localhost/xyz/d/_0uzUTWZZw/message?orgId=1&var-id=2)  
if such url requested contains string var-id then set another value to variable.

location /xyz/ {  
if ($request\_uri ~\* “/xyz/.+?orgId”){  
set $xyzuser TestingAuthUser1;   
}  
if ($request\_uri ~\* “/xyz/.+?orgId.+var-Id”){  
set $xyzuser TestingAuthUser2;   
}  
proxy\_set\_header X-WEBAUTH-USER “${xyzuser}”;  
}

How can I achieve this scenario in nginx. Please suggest.
