Welcome! Log In Create A New Profile

Advanced

Nginx URL rewrite changes URL

Posted by maxim.dsouza 
Nginx URL rewrite changes URL
March 21, 2013 07:20AM
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.
Re: Nginx URL rewrite changes URL
March 22, 2013 02:56PM
rewrite ^/dentists/([a-z]+)/([a-z]+)/?$ /doctorsInArea.htm?cID=$1&aID=$2;

Does this work? You don't want to use http:// for rewrite



Edited 1 time(s). Last edit at 03/22/2013 02:57PM by voodooKobra.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 180
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