doukui4836 2014-05-14 02:30
浏览 62
已采纳

使用Slim Framework进行Nginx配置,如何保留.php网址

My server has just wiped out by the provider, and I don't have the backup of the Nginx configuration file. It was completely lucky I got it working, now I don't know what to do.

So I am having multiple files to do some specific things, and I am using Slim Framework on each file. The idea is to keep the php extension on the URL. Something like this:

www.example.com/service.php/customer/1
www.example.com/api.php/data
www.example.com/test.php/other-data/5

Does anyone have some clue on this? I really forgot what I did before with the configuration.

Thank you in advance

  • 写回答

2条回答 默认 最新

  • dongyinpan9284 2014-05-27 04:56
    关注

    If somehow someone goes here, I finally found the answer.

    server {
    listen   80; ## listen for ipv4; this line is default and implied
    
    root /usr/share/nginx/www;
    index index.html index.htm;
    
    # Make site accessible from http://localhost/
    server_name localhost;
    
    location / {
    }
    
    location /doc/ {
        alias /usr/share/doc/;
        autoindex on;
        allow 127.0.0.1;
        deny all;
    }
    
    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        if (!-f $document_root$fastcgi_script_name) {
          return 404;
        }
        include fastcgi_params;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
    }}
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容