non-existing subdomains show default index page

Discussion in 'General' started by meereck, Aug 11, 2013.

  1. meereck

    meereck New Member

    Hello,
    I have been experiencing this:
    When I open a non-existing subdomain of a domain hosted on my server (such as asdjkajsdl.mydomain.com), it shows the content of /var/www/index.html.
    This relates to all domains that are on the server.
    existing ones, say www.mydomain.com, behave correctly.

    I can also see that visiting asdjkajsdl.mydomain.com adds a line to /var/log/apache2/access.log, not to the domain access log, which means that it does not recognize that the request is through a domain.

    The correct behaviour is to return a domain's default 404 or at least a default Apache 404 page?
    Does anybody have a clue what might be wrong?

    Cheers, Meereck
     
    Last edited: Aug 11, 2013
  2. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    The behaviour you see is intended and expected.
    If a subdomain points to your server in DNS it should be set up on the server. If it is not, the first apache vhost for the non-existing subdomain is used.

    You can change this in the following ways, while I think the second might be the one of your choice and in my opinion is preferable:

    1.) only create those dns entries for subdomains you use and no * host dns entry

    2.) set the auto-subdomain setting in ISPConfig to "*" and not to "none" or "www" in the website settings.
    This will redirect all requests to non-existing subdomains to the main domain, where you can handle them with .htaccess and things like that.

    3.) create your own php script in /var/www/ and enable php on your server for this directory. Let the php script decide what to do with incoming requests to non-existing subdomains. You could even send 404 header there - even though I don't think this error should be used for that case.
     
  3. meereck

    meereck New Member

    Hi, thanks.
    I might have misunderstood the general usage.
    Are you saying a common practice is to point only those subdomains in DNS that are used?
    What auto-subdomain option in ISPConfig is then suggested?

    Cheers
     
  4. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    It totally depends on your needs, as I said there are multiple ways to deal with non-existing subdomains.

    I myself use the /var/www to place a message in the index.html that says "domain you called does not exist".
    But indeed it is a common practice to only set used subdomains in dns, so unused won't even resolve. This is no option, if you have clients that can create subdomains in ISPConfig themselves.
     
  5. meereck

    meereck New Member

    Thanks for clarification.
    Crystal clear now.

    Cheers, Meereck
     

Share This Page