By gongsun
I follow this step How To Set Up Apache Virtual Hosts on Ubuntu 16.04
when i type example.com it’s show example.com when i type subdomain.example.com it’s show subdomain.example.com when i type my server ip it’s show subdomain.example.com
my problem is i want to set my server ip to show example.com or not show anything. where can i set it.
Thanks.
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!
Default virtual host will be the first loaded one. If you have multiple virtual hosts in same file, first from file will be default. If you have them in multiple files, VHost in first file will be default.
File are sorted alphabetical, with files starting with digit having highest priority:
Example000-default.conf
an.example.com.conf
example.com.conf
So let’s say you have enabled following hosts (you can see enabled hosts using ls -l /etc/apache2/sites-enabled):
Sample Outputan.example.com.conf
example.com.conf
You want example.com to be default but it isn’t.
Disable it using a2dissite:
- sudo a2dissite example.com
Now rename it so it comes before an.example.com:
- sudo mv /etc/apache2/sites-available/example.com.conf /etc/apache2/sites-available/000-example.com.conf
Enable it once again and restart Apache:
- sudo a2ensite 000-example.com
- sudo systemctl restart apache2
Try to visit site via IP, it should be working correctly this time.
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.