@osprey already pointed out that you must use hostnames. Delete the "https://" or "http://" that comes before the hostname. You must also delete anything that follows the top level domain (TLD). The top level domain is the ".com" or ".org" or ".zn" in the OP's original post. Anything that follows the top level domain in a web address is not part of the hostname and should be deleted. They often start with "/" or "?".
Look at the address bar for this webpage. If you want to add linux.org to your hosts file, you would delete "https://" and also delete "/threads/my-question..." to get the hostname for this website. The hostname is "
www.linux.org". The hostname includes the "www."
Hostnames are unique. "
www.linux.org" is different than "linux.org". A DNS lookup takes a hostname and returns an IP address for it. The IP address for "
www.linux.org" could be different than the IP address for "linux.org", or it could be the same. If a website uses web addresses with and without "www.", then you may need two entries in your host file to fully block it.
The hosts file is a list of replacements for DNS IP address lookups. Your entries in the hosts file override all other DNS lookups. If there is an entry in your hosts file for a given hostname, it "wins" over the DNS server on the internet that your system normally uses.
The way that this hosts file trick works is to point the hostnames for blocked websites to your localhost (127.0.0.1). It is guaranteed to be the "local IP address" for your computer, so the website is blocked.