Wordpress使用htaccess密码保护网站

时间:2015-08-22 05:41:39

标签: wordpress apache .htaccess security

我厌倦了为我的WordPress网站实施htaccess密码保护,用户在输入htaccess用户名和密码后需要查看我的网站,我使用下面的代码并显示密码输入框,

我的htaccess文件

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
AuthName "Restricted Area" 
AuthType Basic 
AuthUserFile .htpasswd 
AuthGroupFile /dev/null 
require valid-user
<Files 403.shtml>
order allow,deny
allow from all
</Files>

deny from 141.101.99.132
deny from 173.245.53.65
deny from 173.245.53.74

但输入密码后会显示服务器错误消息

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@daqta.lixdea.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

我的网站是http://www.daqta.com/用户名 - 测试,密码测试

1 个答案:

答案 0 :(得分:0)

在apache配置中使用与此类似的内容。

<Location />
     AuthType Basic
     AuthName "username"
     AuthUserFile /etc/httpd/htpasswd
        Require valid-user
</Location>

其中/ etc / httpd / htpasswd是密码文件