I try to configure virtualhost with Apache2 on Ubuntu like that (LAMP Stack on docker) :
- test1.domain.com -> /var/www/html/test1
- test2.domain.com -> /var/www/html/test2
- test3.domain.com -> /var/www/html/test3
The path root is /var/www/html
My virtual host has configurated for ssl too.
When i try to call url with ssl (https), it's work, but if i try without ssl (http), i go to path root (/var/www/html). I don't understand why.
- https://test1.domain.com -> /var/www/html/test1 = OK
- http://test1.domain.com -> /var/www/html = NOK
I also need to redirect http to https.
Default VHOST File :
<VirtualHost 192.168.32.3:80>
ServerAdmin webmaster@localhost
DocumentRoot ${APACHE_DOCUMENT_ROOT}
ServerName 192.168.32.3
ServerAlias 192.*
ServerAlias *:*
<Directory ${APACHE_DOCUMENT_ROOT}>
Options Indexes MultiViews
AllowOverride All
</Directory>
</VirtualHost>
# Allows HTTPS on localhost. You will need to use mkcert on your local machine
# to create the `cert.pem` and `cert-key.pem` files, and then place them in the
# `./config/ssl` directory. You could also create certificates for any local
# testing domain you wish such as `localapp.test`, you will then edit your hosts
# file to map that domain name to 127.0.0.1 and then configure your vhosts below
# accordingly:
#
# <VirtualHost *:443>
# ServerAdmin webmaster@localhost
# DocumentRoot ${APACHE_DOCUMENT_ROOT}
# ServerName localhost
# <Directory ${APACHE_DOCUMENT_ROOT}>
# AllowOverride all
# </Directory>
# SSLEngine on
# SSLCertificateFile /etc/apache2/ssl/cert.pem
# SSLCertificateKeyFile /etc/apache2/ssl/cert-key.pem
# </VirtualHost>
VHOST File test :
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot ${APACHE_DOCUMENT_ROOT}/test
ServerName test1.domain.com
<Directory ${APACHE_DOCUMENT_ROOT}/test>
Options Indexes MultiViews
AllowOverride All
</Directory>
</VirtualHost>
# Allows HTTPS on localhost. You will need to use mkcert on your local machine
# to create the `cert.pem` and `cert-key.pem` files, and then place them in the
# `./config/ssl` directory. You could also create certificates for any local
# testing domain you wish such as `localapp.test`, you will then edit your hosts
# file to map that domain name to 127.0.0.1 and then configure your vhosts below
# accordingly:
#
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot ${APACHE_DOCUMENT_ROOT}/test
ServerName test1.domain.com
<Directory ${APACHE_DOCUMENT_ROOT}/test>
AllowOverride all
</Directory>
SSLEngine on
/// CERTIFICATE CONFIG ///ls
</VirtualHost>