nginx block URI request but allow internal directory
- by Mike Anders
I'm new to nginx from apache. I'm trying to simply block the URIs:
/_mydir/* = / (redirect)
But, I want to rewrite:
/ex/(.*)$ = /_mydir/$1
I have tried:
location /ex/ {
rewrite ^/ex/(.*)$ /_mydir/$1 last;
}
location /_mydir {
rewrite ^/_mydir/(.*)$ http://$http_host/ redirect;
}
But what always happens is once I block the '/_mydir' directory the rewrite is also blocked.
I have also tried: location /_mydir/ { internal; }
This also ends up blocking the rewrite.
All help is greatly appreciated, thanks.
UPDATE: I fixed this problem using: rewrite ^/ex/(.*)$ /_mydir/$1 break;