Here is a situation
I have example.com
domain pointed to my server where Apache2 runs.
Currently I have two confs (one for HTTP and one for HTTPS) that accepts example.com requests and shows page thats stored in folder /var/ww/html/example
HTTP conf (example.com.conf
)
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/example
ServerName example.com
ServerAlias www.example.com
ErrorLog logs/example.com-error_log
CustomLog logs/example.com-access_log common
Redirect permanent / https://example.com
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
HTTPS conf is basic conf generated by certbot
with no changes
But what I want to achieve now is to have subdomain demo.example.com
which simply points to root html folder /var/www/html/
(so if I type demo.example.com/some-folder
is shows content of this folder)
So I´ve tried this
HTTP conf (exampledemo.com.conf
)
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName demo.example.com
ServerAlias www.demo.example.com
ErrorLog logs/demo.example.com-error_log
CustomLog logs/demo.example.com-access_log common
Redirect permanent / https://demo.example.com
RewriteEngine on
RewriteCond %{SERVER_NAME} =demo.example.com [OR]
RewriteCond %{SERVER_NAME} =www.demo.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
HTTPS conf is basic conf generated by certbot
with no changes
But when I added site and restarted apache, I am getting not found page that I have on my server as fallback so this configuration probably does not match my conf
HTTP conf (000-default.conf
)
<VirtualHost *:80>
DocumentRoot /var/www/html/not-found
</VirtualHost>
Can anyone please tell me what I am doing wrong?