NixUser

NixUser.com | Unix User | Linux User | NixUser

WordPress Password Protection and mod_rewrite error

 

I have added the following to my .htaccess file (password protected) to limit the access to wordpress login pages.

 

ErrorDocument 401 “Unauthorized Access”
ErrorDocument 403 “Forbidden”

<FilesMatch “wp-login.php”>
AuthName “Authorized Only”
AuthType Basic
AuthUserFile /home/user/.htpasswd
require valid-user
</FilesMatch>

 

But after the change, the page won’t load, it gave out a infinite loop error.

 

The problem is that accessing protected content makes Apache send a 401 header.

 

Turning off mod_rewrite after the errordocument lines did the trick for me. After the changes, htaccess file looked like.

 

ErrorDocument 401 “Unauthorized Access”
ErrorDocument 403 “Forbidden”

RewriteEngine off

<FilesMatch “wp-login.php”>
AuthName “Authorized Only”
AuthType Basic
AuthUserFile /home/user/.htpasswd
require valid-user
</FilesMatch>