I need rewrite rule for my nginx server without changing the url.
For example :
The following link
http://example.com/old/path/index.php?cid=XXhhHHnmmm
to become :
http://example.com/newpath/index.php?cid=XXhhHHnmmm
and to point in that specific folder (/old/path).
till now I've tried the following which is working if I try opening
_http://example.com/newpath:
but not working if I try
_http://example.com/newpath/index.php?cid=XXhhHHnmmm
location ~ /old/path {
rewrite "/old/path" http://www.example.com/newpath$2 break;
}
I've also tried with proxypass :
location /newpath {
proxy_pass http://www.example.com/old/path;
}
but still not working as desired.
Try
location ~ ^/newpath {
rewrite ^/newpath/(.*) /old/path/$1 break;
}