By johnaraon
I have purchased a digital ocean droplet running Apache and have linked it with a domain example.com. Currently in some 11 digit IP address after type in the browser like 137.152.33.173 I can view the website and so can the public. My droplet is running on Ubuntu 18.04 LTS. How would I go about only allowing access when typed in example.com and www.example.com but just make the browser keep on trying but be unable to access directly using the IP address? Thank you.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
What I could suggest is adding a Vhost for your website as described here:
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-16-04
After that in your default Vhost, change the document root so that it does not match the document root of your site.
For example:
In your websites Vhost set the document root to /var/www/yourdomain.com and put your website files there
And in your default Vhost set the document root to: /var/www/html and put the default Apache index.html file there
That way if someone visits your domain name they would get the content from /var/www/yourdomain.com and if someone visits your IP they would just get the Apache default page from /var/www/html.
Hope that this helps! Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.