Rewrite uri to lowercase in nginx webserver


 

We want make our uri case insensitive. What it is? When I call uri like https://manpages.cz/INdex.html, so such uri will be first rewrite to all lowercase chars like https://manpages.cz/index.html.

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:

 

Explanation


 

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:

 

Related Post

Apache server – Terms Used to Describe Direc... Have you sometime a question what is url, url-path, file-path, regex, mime-type and more? The answer is in this article. We describe a basic terms use...
How Does Apache Decide Order to Execute Modules? I have a question for all. Modules such as mod_dir, mod_alias, mod_rewrite... how does Apache determine what order to process them?   Apache ...

Pin It on Pinterest