问题描述
我的服务器刚刚被提供程序清除,我没有Nginx配置文件的备份.我真的很幸运,现在它能正常工作了,现在我不知道该怎么办.
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.
因此,我有多个文件要做某些特定的事情,并且我在每个文件上使用Slim Framework.这个想法是将php扩展名保留在URL上.像这样:
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
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.
提前谢谢
推荐答案
如果有人以某种方式来到这里,我终于找到了答案.
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;
}}
这篇关于使用Slim Framework配置Nginx,如何保留.php网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!