0

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 !

1 Answers1

0

You need to set up a default virtual host, which sends 404 HTTP not found to visitors. Default virtual host covers all connections where the requested host does not match an existing virtual host.

https://stackoverflow.com/questions/5427379/apache-default-virtualhost has many options for setting an Apache2 default virtual host.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63