We get information from $_SERVER['REQUEST_URI'] not from $_GET or $_POST.
I want to define $request_uri to change /example to /module/controller/action. Please note that I do not want to trigger a redirect.
I tried the code below to do this, but it doesn't work.
location /example {
    rewrite /module/controller/action;  
}
                According to NGINX documentation, $request_uri is the original request (for example, /foo/bar. php? arg=baz includes arguments and can't be modified) but $uri refers to the altered URI.
set $request_url $request_uri;
if ($request_uri ~ ^/example(.*)$ ) {
    set $request_url /module/controller/action;
}
location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9090;
    #include        fastcgi.conf;
    fastcgi_param  REQUEST_URI        $request_url;
    #fastcgi_param  REQUEST_URI        $request_uri;
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With