vedran
By:
vedran

Nginx If /something.php is called act as http://www.stgelse.com/xyz is opened

April 2, 2015 485 views
Nginx LEMP Apache

I want to open IP/something.php and to see everything as if i opened http://anotherserver.com/path

And without redirections, preserving URL1 and pass all GET params to URL2

URL1: "http://182.6.15.191/something.php"
URL2: "http://www.example.com/another"

I tried something like this, but nginx proxy mod is quite huge to understand

location /something.php {
proxy_pass http://somethingelse.com/else;
proxy_set_header Host $host;
}

But this redirects URL and seems like doesn't pass GET params

p.s. in apache it was all possible just with mod_proxy and two lines

    ProxyPass /filename.php http://someurl.com/something
    ProxyPassReverse /filename.php http://someurl.com/something
1 comment
  • Use the following line

    location /my/ {
        rewrite ^ /my.php?$1 last;
    }
    

    matching it with your details.

    edited by asb
Be the first one to answer this question.