我想将此lighttpd重写规则转换为nginx重写代码。
alias.url += ( "/ui/" => "/usr/local/opnsense/www/" )
alias.url += ( "/api/" => "/usr/local/opnsense/www/" )
url.rewrite-if-not-file = ( "^/ui/([^\?]+)(\?(.*))?" =>
"/ui/index.php?_url=/$1&$3" ,
"^/api/([^\?]+)(\?(.*))?" => "/api/api.php?
_url=/$1&$3"
)
我尝试了以下代码,但无法正常工作
location /ui/ {
alias /usr/local/opnsense/www/;
rewrite ^/ui/([^\?]+)(\?(.*))? /ui/index.php?_url=/$1&$3 last;
}
location /api/ {
alias /usr/local/opnsense/www/;
rewrite ^/api/([^\?]+)(\?(.*))? /api/api.php?_url=/$1&$3 permanent;
}