Apache will try to match a web request with the configured domains in the order they appear in the file system and within the configuration files. As a general rule of thumb, it's better to have subdomains handled before the main site, which should be configured to act as a "catch-all" for any traffic that is unhandled.
With this in mind, your configuration file could be updated to look like this:
<VirtualHost *:8080>
ServerAdmin [email protected]
ServerName government-jobs.azaanjobs.com
ServerAlias www.government-jobs.azaanjobs.com
DocumentRoot /var/www/government-jobs/public_html/
<Directory /var/www/government-jobs/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin [email protected]
ServerName azaanjobs.com
ServerAlias www.azaanjobs.com *.azaanjobs.com
DocumentRoot /var/www/azaanjobs/public_html
<Directory /var/www/azaanjobs/public_html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/azaanjobs.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/azaanjobs.com/privkey.pem
</VirtualHost>
</IfModule>
Notes:
- the updated configuration file replaces the incorrect
www.government-jobs.azaanjobs.com.com
value for ServerAlias
with a proper .com
reference
- a
*.azaanjobs.com
alias was added to the main domain to ensure any "unexpected" traffic is captured and routed to a probable location
- there does not seem to be any configuration on the main site for
*:80
, which could be an issue if the something in front of the server is not converting non-SSL traffic to use SSL
- the subdomain is still listening on port
8080
, so this will need to be updated to *:80
before visitors can see the site without specifying the port in their browser
Remember to restart Apache after changing the configuration file:
sudo service apache2 restart
This should give you what you need