Rewrite uri to lowercase in nginx webserver


We want make our uri case insensitive. What it is? When I call uri like, so such uri will be first rewrite to all lowercase chars like

For nginx webserver we have a two choices – perl and lua module


Perl module to nginx case insensitive rewrite


  • we need install libnginx-mod-http-perl module for nginx webserver

  • enable libnginx-mod-http-perl module in nginx webserver and reload configuration

  • to http context in nginx write this configuration

  • And to your virtual host add this config:




We known Nginx Location directive priority and selection algorithm from this article – nginx location manual.

Search of regular expressions terminates on the first match, and the corresponding configuration is used. So, we make our uri to lowercase location as a first location context in our configuration. When uri is rewrite to lowercases, we than make another location context that match such uri as lowercase prefix or lowercase regular expression.


Rewrite uri to lowercase in apache webserver

We need add this config to our virtual host as the first rewrite rule:



Pin It on Pinterest