我尝试了无数通配符/正则表达式组合,但下面的代码都无济于事。基本上只是希望它能捕获文件夹的任何子目录/protected/
。如果我对特定文件夹使用以下代码,它会起作用,但如果我尝试类似的东西location ^~ /protected/*/
,location ^~ /protected/[a-zA-Z0-9]+/
它就会崩溃……
有什么建议么?
location ^~ /protected/sub-folder-01/ {
if ($cookie_amember_nr !~* [a-zA-Z0-9]+) { #not authorized
rewrite ^(.*)$ /members/protect/new-rewrite?f=5&url=$request_uri?$args redirect;
}
set $file $document_root/members/data/new-rewrite/$cookie_amember_nr-5;
if (!-f $file) { #have not access
rewrite ^(.*)$ /members/no-access/folder/id/5?url=$request_uri?$args redirect;
}
#everything is ok
}
谢谢你!