简体   繁体   English

如何在nginx中更改$ request_uri?

[英]How to change $request_uri in nginx?

We get information from $_SERVER['REQUEST_URI'] not from $_GET or $_POST . 我们从$_SERVER['REQUEST_URI']获取的信息不是来自$_GET$_POST

I want to define $request_uri to change /example to /module/controller/action . 我想定义$request_uri来将/example更改为/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;  
}
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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM