I've tried countless wildcard/regex combinations to no avail for the below code. Basically just want it to capture any sub-directory of the /protected/
folder. If I use the below code for a specific folder, it works, but if I try stuff like location ^~ /protected/*/
or location ^~ /protected/[a-zA-Z0-9]+/
it breaks...
Any suggestions?
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
}
Thank you!