Home > Backend Development > PHP Tutorial > 【在线等】请问这个地址怎么实现重写?

【在线等】请问这个地址怎么实现重写?

WBOY
Release: 2016-06-23 13:52:54
Original
922 people have browsed it

原始地址:
http://172.16.46.40/api/handler.php/user/1/get_info/6

现在需要在nginx 里面配置 最终得到这样的结果,就是
可以通过访问
http://172.16.46.40/api/user/1/get_info/6  一样可以正常访问,请问在Nginx里面怎么配置?  


回复讨论(解决方案)

        if (-f $request_filename) {
            break;
        }

        # otherwise rewrite it
        if (!-e $request_filename) {
            rewrite ^(.+)$ /handler.php?_url=$1 last;
            break;
        }

        if (-f $request_filename) {
            break;
        }

        # otherwise rewrite it
        if (!-e $request_filename) {
            rewrite ^(.+)$ /handler.php?_url=$1 last;
            break;
        }



不可以,真的,现在直接出现:file not found ,那个红色的框是我那个URL的pathinfo
我是这样使用的

        if (-f $request_filename) {
            break;
        }

        # otherwise rewrite it
        if (!-e $request_filename) {
            rewrite ^(.+)$ /handler.php?_url=$1 last;
            break;
        }



就算是 丢在那个 我配置的pathinfo下面,也不可以,要么是404,要么就是500错误!!!

你自己放错了位置,就不能怪别人了

       location /{               index index.html index.htm index.php;               if (-e $request_filename) {                       break;               }               if (!-e $request_filename) {                       rewrite ^(.+)$ /handler.php?_url=$1 last;                       break;               }       }
Copy after login
Copy after login

你自己放错了位置,就不能怪别人了

       location /{               index index.html index.htm index.php;               if (-e $request_filename) {                       break;               }               if (!-e $request_filename) {                       rewrite ^(.+)$ /handler.php?_url=$1 last;                       break;               }       }
Copy after login
Copy after login


好嘞!!!
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template