let’s say i have 2 domain and 1 ip address
my virtualhost configuration for domain-one.com :
<VirtualHost *:80>
ServerName domain-one.com
ServerAlias www.domain-one.com
DocumentRoot /var/www/domain-one.com/html
</VirtualHost>
<VirtualHost *:443>
ServerName domain-one.com
ServerAlias www.domain-one.com
DocumentRoot /var/www/domain-one.com/html
SSLEngine on
SSLCertificateFile *ssl_location*
SSLCertificateKeyFile *ssl_location*
SSLCertificateChainFile *ssl_location*
</VirtualHost>
and virtualhost configuration for domain-two.com :
<VirtualHost *:80>
ServerName domain-two.com
ServerAlias www.domain-two.com
DocumentRoot /var/www/domain-two.com/html
</VirtualHost>
It works, but when i visit using ip address without https , apache will using domain-two.com virtualhost
and when i visit using ip address with https, apache will using domain-one.com virtualhost
the question is , is that possible using DocumentRoot /var/www/html when i visit ip address?
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!
Why did you bring up a third site at /var/www/html? Is this site enabled too?
To check, run the following command:
grep -R "DocumentRoot" /etc/apache2/sites-enabled
Does the output list anything about /var/www/html? If not, then the site at /var/www/html is not enabled and therefore will not effect your other 2 sites.
Next question: Does domain-two.com also have an SSL config file?
I’ve seen issues before related to this. You may need one.
Lastly, I didn’t see in your example configs the RewriteEngine on directive. You’ll need this.
Good luck!
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.