wiki:nginx_redirect_rewrites
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
wiki:nginx_redirect_rewrites [2022/09/23 13:28] – add Redirect based on browser's Accept-Language header that is sent antisa | wiki:nginx_redirect_rewrites [2023/01/11 13:43] (current) – add Rewrite uppercase to lowercase antisa | ||
---|---|---|---|
Line 83: | Line 83: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | ===== Rewrite uppercase to lowercase ===== | ||
+ | Install perl module first: | ||
+ | |||
+ | apt install nginx-module-perl | ||
+ | |||
+ | Enable it in // | ||
+ | load_module " | ||
+ | |||
+ | Create perl rewrite function inside //http// section: | ||
+ | <code nginx> | ||
+ | # Include the perl module | ||
+ | perl_modules perl/lib; | ||
+ | |||
+ | # rewrite function from upper to lowercase | ||
+ | perl_set $uri_lowercase 'sub { | ||
+ | my $r = shift; | ||
+ | my $uri = $r->uri; | ||
+ | $uri = lc($uri); | ||
+ | return $uri; | ||
+ | }'; | ||
+ | </ | ||
+ | |||
+ | Use it in site configuration, | ||
+ | <code nginx> | ||
+ | # if the path contains uppercase characters, | ||
+ | # rewrite to lowercase | ||
+ | location ~ [A-Z] { | ||
+ | | ||
+ | } | ||
+ | </ | ||
+ | |||
====== Tested on ====== | ====== Tested on ====== | ||
* Debian 11 | * Debian 11 |
wiki/nginx_redirect_rewrites.1663939730.txt.gz · Last modified: 2022/09/23 13:28 by antisa