C
C
Chvalov2017-09-01 02:33:25
Nginx
Chvalov, 2017-09-01 02:33:25

How to convert url to lowercase using nginx?

How to redirect url addresses to lower case?
there is a product page:
https://beauto.com.ua/product/kyb-amortizator-gazo... - norms
https://beauto.com.ua/product/kyb-AmORtiZAtor-GAZo... - badly
desirable way without using perl and lua

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan, 2017-09-01
@helpik94

I can offer such variant with perl. First you need to install perl on the server.
Find http {} and write in brackets

<span style="font-size:16px;"><span style="font-family:arial,helvetica,sans-serif;"> http {
 
perl_modules perl/lib;
 
perl_set $uri_lowercase ‘sub {
 
my $r = shift;
my $uri = $r->uri;
$uri = lc($uri);
return $uri;
}’;
 </span></span>

We save
<span style="font-size:16px;"><span style="font-family:arial,helvetica,sans-serif;">location ~ [A-Z] {
rewrite ^(.*)$ $scheme://$host#uri_lowercase;
 
}
 </span></span>

Save
Now everything redirects to lowercase, so make sure you don't have case sensitive URLs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question