0

I need help with nginx redirection

I want to redirect:

example.com/new-clock/?bc=search&search_id=202 to www.example.com

I have used this code in nginx config

rewrite ^/new-clock/?bc=search&search_id=202$ https://www.example.com/ permanent;

But it shows 404, when I remove the query string (?bc=search&search_id=202) and keep only

rewrite ^/new-clock/$ https://www.example.com/ permanent; 

then it redirects to www.example.com/?bc=search&search_id=202

I want it to redirect to www.example.com only, dont want query string in final destination.

Thanks :)

Dark9Y8
  • 41
  • 5

1 Answers1

0

If this works for you:

rewrite ^/new-clock/$ https://www.example.com/ permanent;

Then just change the permanent to redirect at the end of line.

Best regards.

Stefano Martins
  • 1,221
  • 8
  • 10
  • No, its not working. It show query string at the end of destination url. How to strip the query string? – Dark9Y8 Feb 01 '20 at 15:33