search

Home  >  Q&A  >  body text

php - nginx reverse proxy how to handle multiple with rewrite? Request parameter problem

nginx reverse proxy configuration:

This is when I visit lbj.com/faq, it is proxy to lbj.com/index.php?r=index/faq, but because the domain name of the reverse proxy adds request parameters, and then when I use the domain name to add request parameters: lbj.com/faq?xxx=xxx.., because of multiple The request parameters are defined, so this will not take effect and an error will be reported. . (lbj.com/index.php?r=index/faq?xxx=xxx), I want this link to become: lbj.com/index.php?r=index/ How to implement faq&xxx=xxx? I tried some rewrite to rewrite the request parameters I submitted, changing ? into &, but for various reasons I always couldn't get it right. .

PHP中文网PHP中文网2824 days ago558

reply all(1)I'll reply

  • 仅有的幸福

    仅有的幸福2017-05-16 13:14:03

    You don’t need to use a reverse proxy for this! You are originally under the same domain name, so just rewrite will be enough

    You configure it like this:

    location / {
            index  index.php index.html;
            if (!-e $request_filename) {
                  rewrite ^/(.*)$ /index.php?r=index? last; 
                  break;
            }
    }

    reply
    0
  • Cancelreply