Nginx - 多个可选的php参数

时间:2014-09-13 12:30:15

标签: php regex nginx

我根据这个答案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/

我无法让它发挥作用。

0 个答案:

没有答案