nginx重写login和login/在一个语句

目前我正在使用

location /login { rewrite ^/login/$ /login.php last; rewrite ^/login$ /login.php last; } 

重写www.example.com/login和www.example.com/login/。 我想知道这是否也可以在一个声明。 我试着rewrite ^/login(/)$ /login.php last; 但它没有工作。

另外我注意到,自从我开始使用重写,我的一些CSSpath被打破,因为我使用了相对path。 我将把它们全部转换成绝对path,但问自己在使用重写时是否还有更多的含义需要注意。

编辑:

这是我如何处理.php

 location ~ \.php$ { if (!-f $request_filename) { return 404; } fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; try_files $uri $uri/ /index.php; } 

 location /login { rewrite ^/login/?$ /login.php last; } 

在RegEx中,问号使前面的标记可选。