Welcome! Log In Create A New Profile

Advanced

Re: Nginx Lowercase URL and Redirection

Francis Daly
April 19, 2020 02:48PM
On Sat, Apr 18, 2020 at 11:05:36AM -0400, mustafa.chapal wrote:

Hi there,

> First, URLs like www.example.com/new-arrivalS which include a character like
> hyphen are not triggering on the following location.

Works for me. What other location do you have that does handle this
request?

==
location ~ [A-Z] {
return 200 "Does match A-Z\n";
}
location / {
return 200 "Does not match A-Z\n";
}
==
$ curl http://127.0.0.1/new-arrivalS
Does match A-Z
$ curl http://127.0.0.1/new-arrivals
Does not match A-Z


> Second, URLs like www.example.com/dealS?p=2 get redirected to
> www.example.com/deals instead of www.example.com/deals?p=2
>
> location ~ [A-Z] {
> return 307 $scheme://$host$my_uri_to_lowercase;
> }
>
> Kindly help me resolve both the issues.

Either change your $my_uri_to_lowercase to include the query string;
or change the return line to be

return 307 $scheme://$host$my_uri_to_lowercase$is_args$args;

http://nginx.org/r/$is_args and http://nginx.org/r/$args for details.

Good luck with it,

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Nginx Lowercase URL and Redirection

mustafa.chapal April 18, 2020 11:05AM

Re: Nginx Lowercase URL and Redirection

Francis Daly April 19, 2020 02:48PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 323
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready