Apache rewrite - get original URL in PHP

后端 未结 3 826
悲&欢浪女
悲&欢浪女 2020-11-29 08:43

I have a rewrite in nginx or Apache for this address:

http://domain.com/hello

to a script like

http://domain.com/test.php&a         


        
3条回答
  •  清歌不尽
    2020-11-29 09:19

    In Nginx conf, we need to add user header with request_uri:

    proxy_set_header request_uri $request_uri;
    

    And read it in php:

    echo $_SERVER['HTTP_REQUEST_URI'];
    

    upd

    for some reason nginx don't like symbol '_' in header name, don't know how it worked before, maybe something changed after nginx update. Now i'm using

    proxy_set_header rewriteduri $request_uri;
    

    and in php

    $_SERVER['HTTP_REWRITEDURI']
    

提交回复
热议问题