I am using nginx 1.14.0 on Ubuntu.
I want anyone coming to https://www.example.com/blog/authors/
should always redirected to https://www.example.com/blog
which is working fine, but if anyone comes through https://www.example.com/blog/authors/?hello
(with question mark) is being forwarded to https://www.example.com/blog/?hello
Why is it doing like this? and how can I correct my nginx configuration settings so even if anyone types in anything with question mark '?' to https://www.example.com/blog/authors/?hello
should always forwarded to https://www.example.com/blog/
as well.
This is my redirect rule
# Redirects to handle all of the URL patterns from the old site
rewrite ^/blog/authors/$ /blog/$1 permanent;
And, following is my complete nginx config block file
server {
listen 80;
listen 443 ssl;
server_name example.com www.example.com;
access_log /var/log/nginx/example.com.access.log;
ssl_certificate /etc/nginx/ssl/example.com.crt;
ssl_certificate_key /etc/nginx/ssl/example.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /my/server/site/path;
}
location / {
include proxy_params;
proxy_pass http://unix:/my/server/site/path/site.sock;
}
# Redirects to handle all of the URL patterns from the old site
rewrite ^/blog/authors/$ /blog/$1 permanent;
}
I have seen this answer to other question https://stackoverflow.com/questions/44782411/nginx-rewrite-question-mark but not sure exactly where do I need to make appropriate changes?