Reputation: 396
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;
}
Upvotes: 10
Views: 47550
Reputation: 9082
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;
}
Upvotes: 20