我希望能够将漂亮的 URL 映射到 nginx 网站的文件系统。但是,我不知道它如何工作。我想获取一个 URL 并将/action/method/param/param2/
其映射到/action/method.php/param/param2
。根据nginx 文档类似这样的事情应该有效。
location / {
include fastcgi_params;
# regex: word / word (followed by anything)
fastcgi_split_path_info ^(\w+/\w+)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_pass 127.0.0.1:9000;
}
答案1
尝试在第一组中添加“/”:
fastcgi_split_path_info ^(/\w+/\w+)(.*)$;