Step 1: come to the directory you want to protect, create a file index.php
which has
1 2 3 | <?php phpinfo(); ?> |
and get the home directory from DOCUMENT_ROOT
Step 2: modify .htaccess and add this snippet
1 2 3 4 5 | AuthType Basic AuthName "restricted area" AuthUserFile /home4/ninscore/public_html/dengph/.htpasswd # AuthUserFile {DOCUMENT_ROOT/.htpasswd} require valid-user |
Step 3: create .htpasswd
the password is usually MD5
https://shop.alterlinks.com/htpasswd/htpasswd.php
Some errors:
- Which directory will be locked depends on which .htaccess you modify.
- You may get Internal Error since your Document_Root is wrong, it should be same as phpinfo();
- It keeps asking password. You need to use the attached link to get your generated password.