You may want to restrict the development site from search engine or from direct access. One of the popular way of doing so is to use Apache2 Basic Authentication.
Here we will be discussing on how to password protect your development site using Apache2 Basic Authentication which makes a use of .htaccess & .htpasswd files.
1. Create & upload .htaccess file to the root of your dev site with the following content:
AuthName "Authorisation Required" AuthUserFile "/path/to/.htpasswd" AuthType Basic require valid-user ErrorDocument 401 "Authorisation Required"
Notes: If .htaccess file already exists then you can add the above code on the top.
Also note that omitting ‘ErrorDocument 401 “Authorisation Required”‘ line can lead to 404 error.
2. Create & upload the .htpasswd file to ‘AuthUserFile’ path with the following content:
Notes: Where ‘foo’ is the username and ‘$apr1$yB1.9vIT$IVVBmq5vMauwsNR8CZdHQ.’ is the MD5 encrypted password of ‘bar’.
That was just an example, in fact you can use any username/password combination.
In order to create encrypted password you can use some free online tool like:
3. Now try to visit the dev site, you will get the screen similar as:
And you will only be able to browse the dev site once the correct username/password are entered.
Hope this helps you in password protecting your site.