Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

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!
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.
Hi there!
It looks like you’ve set up the VirtualHost for the second site correctly for port 80, but if you’re accessing the site via HTTPS, you’ll also need to create a VirtualHost block for port 443, similar to what you’ve done for the original site.
What you could do is use Let’s Encrypt to get a free SSL and also together with certbot it will automatically configure your Apache virtual host for port 443:
Hope that this helps!
Best,
Bobby
Heya,
It seems you have a few issues that might be contributing to the problem:
Overlap of <VirtualHost *:80> Blocks: Your originalsite.com configurations have multiple overlapping blocks that can confuse Apache on how to handle requests.
RewriteRule and RewriteCond:
originalsite.com will redirect all traffic to www.originalsite.com and further to HTTPS (using the condition %{SERVER_NAME} =originalsite.com). This might catch requests for other sites as well and redirect them.Missing HTTPS for the Second Site: You have no HTTPS configuration for second.com, which might lead to issues if someone tries to access it over HTTPS.
Default Virtual Host: If Apache can’t find a match for the domain in the request, it serves the first <VirtualHost> block it comes across. This might also be causing the redirection.
Let’s address these issues:
Consolidate VirtualHosts for originalsite.com:
Combine the configurations for originalsite.com and www.originalsite.com under port 80:
<VirtualHost *:80>
ServerName originalsite.com
ServerAlias www.originalsite.com
DocumentRoot /var/www/originalsite
RewriteEngine On
RewriteCond %{HTTP_HOST} ^originalsite\.com$ [NC]
RewriteRule ^(.*)$ http://www\.originalsite\.com$1 [R=permanent,L]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]
</VirtualHost>
Setup the Second Site:
Make sure that you have enabled the vhost for second.com:
sudo a2ensite second.com.conf`
Also, check that there is no conflicting `ServerName` or `ServerAlias` in other configurations.
Add HTTPS Configuration for Second Site:
Ensure that second.com also has an HTTPS (port 443) <VirtualHost> block similar to originalsite.com.
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName second.com
DocumentRoot /var/www/second
# ... SSL configurations ...
</VirtualHost>
</IfModule>
Ensure No Other Conflicting Configurations:
Check other configurations under sites-available and sites-enabled to make sure no other site is using the ServerName or ServerAlias directive that conflicts with your sites.