sudo vi /etc/apache2/apache2.conf (没有的话,可以尝试sudo vi /etc/apache2/sites-available/000-default.conf)打开apache配置文件 <Directory /var/www/> #实际目录根据网站根目录而定 …
August 15, 2018
htaccess: 为某个重写地址加密, Password protection for a single .htaccess rewrite
.htaccess
SetEnvIfNoCase Request_URI "^/my-controller" SECURED # enforce auth if SECURED AuthType Basic AuthName "Login" AuthUserFile /var/www/html/.htpasswd Require valid-user Order allow,deny Allow from env=!SECURED Satisfy any
设置好 .htpasswd 文件,打开 your-domain.com/my-controller 后,就会出现提示框,输入密码!
本文:htaccess: 为某个重写地址加密, Password protection for a single .htaccess rewrite