Hi all,
I have a strange problem. I have multiple domains mapped to one droplet. All of them are working fine. Now, I added a new domain, say, example.com
. This new domain has two other subdomains app.example.com
and engine.example.com
. app
is nodejs app and it’s working fine. engine
is wordpress instance and it’s working fine, too. Now, I want the main domain example.com
to show contents from /var/www/example.com/public_html
. The .conf
file looks like this:
<VirtualHost *:80>
ServerAdmin hi@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
Redirect / https://www.example.com/
<Directory /var/www/example.com/public_html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin hi@example.com
ServerAlias www.example.com
ServerName example.com
DocumentRoot /var/www/example.com/public_html
<Directory /var/www/example.com/public_html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
</Directory>
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/*.example.com/fullchain.pem
SSLCertificateKeyFile /etc/apache2/ssl/*.example.com/key.pem
SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 ! aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS"
</VirtualHost>
</IfModule>
Looks fine to me. Except that visiting example.com
does not redirect to https://www.example.com
. Instead, visiting example.com
shows contents from /var/www/html
. However, visiting https://www.example.com
shows contents from /var/www/example.com/public_html/
What am I missing here?
Also, if it helps, the cname record is
www.example.com example.com
and the a record is
example.com my.droplet.ip
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.
Hello,
Your Vhost looks all good, what I could suggest is to try and update your Redirect rule to:
Hope that this helps! Regards, Bobby