I was setting up a website on DigitalOcean and have messed up because I have modified the etc/hosts file. (That was unnecessary, because I already had setup the nameservers to point to my DO droplet).
Now I don’t know how to restore it to default. Also now when I go to the domain name it gets redirected to var/www/html folder instead of var/www/domain.com folder and the URL is rewritten to IP address.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Could you tell us a little more about what you are trying to accomplish? The problems you are describing sound like they could be related to miss-configuring your webserver (i.e. Apache).
But to answer your question… The default
/etc/hosts
file will look something like this:Where if your
$fqdn
would befoo.example.com
then your$hostname
would befoo
Also,$hostname
should match the output of thehostname
command.