I'm facing a problem, and I don't know what are the best practices for it.
I got a VPS hosting multiple services (DNS, Apache and IMAP/SMTP). The domain is briffoud.fr and each service has its subdomain e.g. smtp.briffoud.fr.
When I browse to smtp.briffoud.fr, for example, it goes the main website, but it shows smtp.briffoud.fr in the address bar.
For now, I use this rewriting rule in Apache :
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.briffoud.fr/$1 [R=301,L]
But it is not very "clean".
How can I prevent the browsing of subdomains corresponding to other services, and what is the best practices to do it ? Should it be done with DNS instead ?
Thanks a lot for your help !