# SEO language URI redirection + existing directories

**URL:** <https://www.ruby-forum.com/t/seo-language-uri-redirection-existing-directories/220667>\
**Category:** NGINX\
**Created:** [June 15, 2012, 6:08pm UTC](https://www.ruby-forum.com/t/seo-language-uri-redirection-existing-directories/220667 "2012-06-15T18:08:37Z")\
**Posts on this page:** 1\
**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:** [June 15, 2012, 6:08pm UTC](https://www.ruby-forum.com/t/seo-language-uri-redirection-existing-directories/220667/1 "2012-06-15T18:08:37Z")

</div>

Hello,

I currently have URI built to have URI like  
website.my/en  
made to send the content from ‘website.my’ in the en language.

My Ngingx conf is as follows:  
location ~\* “^/[a-z]{2}(/.\*)?$” {  
rewrite “^/([a-z]{2})/?$” /index.php?lang=$1 last;  
rewrite “^/([a-z]{2})(/[^.]+)$” $2/index.php?lang=$1 last;  
rewrite “^/([a-z]{2})(/.+)$” $2 last;  
}

I also have some 2-letters top-level directories which I want to send  
with  
the highest priority.

I would like that  
website.my/ab  
checks if /ab directory (or file) exists and:

- process its content as usual if it’s the case
- redirects through the language rules if it’s not

Is there a way to make some conditional rewrite based on the try\_files  
directive?

## Thanks,

_B. R._
