Hide site content from prying eyes
Problem: Sometimes we need closed all our site from prying eyes, how we can do it?
Solution: In this case help us htaccess file.
Step 1: Connect to our hosting use SSH
ssh user_name@host-name.com
Step 2: In the root directory make file .htpasswd use next command, where user_name - login for enter site and password you should enter after command execute
htpasswd -c .htpasswd user_name
Step 3: Make .htaccess file
vi .htaccess
Step 4: Add into the file:
Order deny,allow
Deny from all
RedirectMatch 404 /\\.(svn|git|hg|bzr|cvs)(/|$)
RedirectMatch 404 /README.md$
AuthName "Authorization required!"
AuthUserFile /home/user_name/.htpasswd #Replace on your path
AuthType Basic
Require valid-user
#Allow from 8.8.8.8 #Uncomment and replace IP address, that don't to need block
Satisfy Any
# BEGIN WordPress
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress