NGINX 中把url中的內容當初參數處理

來源:互聯網
上載者:User

標籤:nginx 中把url中的內容當初參數處理

作用:把url為:127.0.0.1/index.php/a/b/c 這樣處理把 post參數: /a/b/c到127.0.0.1/index.phpnginx 配置如下:server {    listen  80;    server_name     127.0.0.1;    root /home/shaddock/Applications/htdocs;    index index.html index.htm index.php index.js;    access_log logs/access.log;    error_log logs/error.log;    error_page 404  /404.html;    location /404.html {root /home/shaddock/Applications/htdocs;    }    location /dmp5.0{index index.html index.htm index.php;if (-e $request_filename) {break;}if (!-e $request_filename) {rewrite ^/dmp5.0/(.*)$ /dmp5.0/index.php/$1 last;break;}    }     location ~ .+\.php($|/) {root/home/shaddock/Applications/htdocs;fastcgi_index index.php;fastcgi_split_path_info ^(.+\.php)(.*)$;fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;fastcgi_param   PATH_INFO               $fastcgi_path_info;fastcgi_param   PATH_TRANSLATED $document_root$fastcgi_path_info;fastcgi_pass   127.0.0.1:9000;include        fastcgi_params;    }}錯誤:2017/01/09 10:48:58 [error] 5103#0: *57 open() "/home/shaddock/Applications/htdocs/dmp5.0/index.php/index/index/ajaxLogin" failed (20: Not a directory), client: 127.0.0.1, server: 127.0.0.1, request: "POST /dmp5.0/index/index/ajaxLogin HTTP/1.1", host: "127.0.0.1", referrer: "http://127.0.0.1/dmp5.0/"上面的錯誤是因為rewrite的時候直接把url http://127.0.0.1/dmp5.0/index.php/index/index/ajaxLogin當成頁面處理了。本意應該是http://127.0.0.1/dmp5.0/index.php/index/index/ajaxLogin這個url把這些單詞參數,傳給http://127.0.0.1/dmp5.0/index.php解決:php中php.ini中下面參數開啟cgi.fix_pathinfo=1

本文出自 “奮鬥吧” 部落格,請務必保留此出處http://lvnian.blog.51cto.com/7155281/1890341

NGINX 中把url中的內容當初參數處理

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.