Вопрос

I have used several rules to block wp-login.php with a htpassword. The htpassword module is working. I added it to root of the site and it worked. But wp-login.php is not working. Here's my website http://www.digitalreborn.com/wp-admin

Here's the passwd rule :

location ~* /wp-login.php {
    auth_basic            "Restricted Area: WordPress";
    auth_basic_user_file  /var/www/digitalreborn/.htpasswd;

    try_files $uri =404;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;

}

Это было полезно?

Решение

Try this approach:

$ htpasswd -bc /tmp/secure_admin.txt admin password

Then on your nginx virtual host conf.

location ^~ /wp-login.php {
    auth_basic           "Restricted Area: WordPress";
    auth_basic_user_file /tmp/secure_admin.txt;
}

Then restart the service:

$ service nginx restart

403 Forbidden after correct login:

This can be caused by permissions or a non-existent or invalid directory index directive.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top