我根据这个答案Nginx URL Rewrite with Multiple Parameters尝试了这个Nginx规则:
location /logs {
rewrite "^/logs/([a-zA-Z]+)/([a-zA-Z]+)/([a-zA-Z]+)/([a-zA-Z]{3})$"
/index.php?y=$1&m=$2&d=$3&view=$4 last;
}
使php接受带有斜杠http://test.com/logs/index.php?y=%s&m=%s&d=%s&view=%s
的参数,例如:
http://test.com/logs/2014/
http://test.com/logs/2014/9/
http://test.com/logs/2014/9/13/
http://test.com/logs/2014/9/13/error/
我无法让它发挥作用。