我有一个 apache htaccess 文件用于Restful API 教程
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)$ api.php?rquest=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ api.php [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -s
RewriteRule ^(.*)$ api.php [QSA,NC,L]
</IfModule>
我的 nginx 配置当前是:
server {
listen 80;
server_name example.org;
access_log /var/log/nginx/access.log main;
location / {
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /404.html
error_page 500 502 503 504 /50x.html;
location = /50x.html
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
如何将其转换为具有重写规则的 Nginx 配置?在文件夹api.php
中root
。