1

I need to redirect a URL in nginx. My rule looks like this which actually causes the browser to visibly change the URL, which is not what is expected.

   location / {
      rewrite ^/dentists/bangalore/indiranagar/$ http://abc.com/doctorsInArea.htm?cID=bangalore&aID=indiranagar break;
    }

I read another question here nginx rewrite WITHOUT change url which tells me to remove the http part . I tried

    location / {
      rewrite ^/dentists/bangalore/indiranagar/$ /doctorsInArea.htm?cID=bangalore&aID=indiranagar break;
    }

This one throws a 404 even though http://abc.com/doctorsInArea.htm?cID=bangalore&aID=indiranagar works fine when hit from the browser. Any insights on the problem would be apprreciated.

2

1 Answer 1

0

I got it working by using the following.

location / {
      rewrite "/dentists/bangalore/indiranagar/" /doctorsInArea.htm?cID=bangalore&aID=indiranagar last;
    }

Thanks!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.