Is it possible to detect if base_auth succeeds in nginx configuration? -
Is it possible to detect if base_auth succeeds in nginx configuration? -
i want protect admin area of site using base_auth, configuration looks
location ^~ /admin/ { auth_basic 'restricted'; auth_basic_user_file /opt/webroot/.htpasswd; # section supposed valid if auth_basic succeeds if (!-e $request_filename ){ rewrite ^/(.*)$ /index.php?$1 last; break; } }
since 'admin' not exist actually, it's virtual path. rewrite rules applies whether authentication succeeds or not.
my question is, it possible apply rewrite rules if auth_basic authenticated?
you utilize try_files
.
location ^~ /admin/ { auth_basic 'restricted'; auth_basic_user_file /opt/webroot/.htpasswd; try_files $uri /index.php; }
nginx
Comments
Post a Comment