redirect to 404 wildcard subdomain

Posted by Leandro Garcia on Server Fault See other posts from Server Fault or by Leandro Garcia
Published on 2012-09-09T16:27:04Z Indexed on 2012/09/10 3:40 UTC
Read the original article Hit count: 510

Filed under:
|
|
|
|

I setup a wildcard A record on my domain registrar. Now if a user access a missing subdomain on my domain, they will be redirected to the homepage. Currently my initial setup was this:

<VirtualHost *:80>
  ServerAdmin webmaster@localhost
  RewriteEngine On
  RewriteRule ^(.*)$ http://domain.com$1 [R]
  DocumentRoot /var/www
  <Directory />
    Options FollowSymLinks
    AllowOverride None
  </Directory>
  # more below...
</VirtualHost>

Any wildcard subdomain or if my IP is entered via URL will redirect to the homepage. Can I do something about this that will redirect (HTTP redirect perhaps) the wildcard subdomains to 404 page instead of to homepage?

© Server Fault or respective owner

Related posts about apache2

Related posts about ubuntu