Reputation: 415
I want to host a private web page that only the intended recipient can see and is invisible to everyone else and doesn't get indexed by all the search engines and is shown as public search result.
I have my own domain and have a paid premium hosting plan.
And the web page consists of just index.html, a css and js file that's all.
So how can i make it private that if others try to open it will get access denied or some error. And the only person I share url can access it?
Upvotes: 0
Views: 4598
Reputation: 23838
URL - is a unique identifier of a shared resource.
For denying access to those who have the url - but you have never had an intention for them to have it, you need to setup a password up front and send the password only to those you think should access your web page.
There are some web servers like Apache, you can set such security easily. I see the answer from Matej Bunček showing this.
Upvotes: 1
Reputation: 49
If you’re using Linux Distribution like Ubuntu, make sure u have installed apache2 and apache2-utils. Then create new user with following command
sudo htpasswd -c /etc/apache2/.htpasswd new_user
And if you want to create another user just leave -c
flag so the command will look like this
sudo htpasswd /etc/apache2/.htpasswd second_new_user
In both cases, you’ll be prompted to enter password for each user.
However, this method is for your global apache2 configuration. Same process can be repeated for only one website. Just make sure, that you have .htaccess
file in your project and then repeat the command. Don’t forget to change path so the command will look like this.
sudo htpasswd -c /var/www/my_website/.htpasswd new_user
Enter the password and then configure .htaccess
like this
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /var/www/my_website/.htpasswd
Require valid-user
If you stick to global apache 2 authentication, then point the change the third line to AuthUserFile /etc/apache2/.htpasswd
Upvotes: 1