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

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -