Problem: Some individuals' ISPs occasionally can't resolve one of my virtual hosts on a LAMP installation. Ubuntu 10.04 LTS, Apache 2. I'm looking for hack that can do it by IP.

Background: On this machine are a number of virtual hosts:

  • default.example.com
  • subdomain1.example.com
  • subdomain2.example.com
  • subdomain3.example.com
  • problemdomain.example.com

  • Which are really housed in:

  • var/www/default.example.com
  • var/www/subdomain1.example.com
  • var/www/subdomain2.example.com
  • var/www/subdomain3.example.com
  • var/www/problemdomain.example.com

  • Occasionally people from some ISPs cannot get to one of the domains, today it's


    HOWEVER these users CAN route to the server via its IP address and receive the default server root landing page:

    WHICH takes them to 'default.example.com'

    Note: The directory i want them to get to is ABOVE the current directory, and directory walking is off.

    IDEA 1: If they can get to the IP of the server and I make a landing directory (default.example.com/foo), can I somehow redirect them to another folder on the server thereby getting them to the right place? How would I do it? * Remember, DNS is not working, so I would think a 301 redirect won't work because it will just tell their browser to look for 'problemdomain.example.com' which they cannot resolve.

    Layspeak rephrasing: Is there a way to tell apache "Hey, if someone requests directory 'foo' on the main server's default web landing page:

    THEN take them to this other virtual host on the server


    Or, is there something like using:

    or some other 'force' to do it? It's not realistic for me to ask end users who have troubles to add hosts entries on their system. Just some way so that for those rare occurrences that DO have a problem I can say something more helpful than "just try a computer on another web connection".

    Much obliged for any help.

    • Do you have a different IP address for each subdomain ? – user9517 May 30 '14 at 19:18
    • nope. one IP with multiple virtual hosts. – Christopher Chirdon May 30 '14 at 19:44
    • That's not an answer to the question I asked. – user9517 May 30 '14 at 19:45
    • Sorry, but nearly same answer. one IP; each subdomain is a different virtualhost entry. – Christopher Chirdon May 30 '14 at 20:08
    • If different individuals using different ISPs occasionally can't resolve one of your domains, the problem is probably on your side. – Dusan Bajic May 30 '14 at 22:19

    Yes and no. Your first layspeak example is easy - you can use URL rewrites. The second layspeak example is probably not possible, but shouldn't be necessary anyway.

    However, this is dependent on the same domain being the problem domain every time - if this is true, the easiest fix is to put the "prblem" domain first in the list. Apache defaults to the first domain listed for that IP if it doesn't get host information. If the problem domain is different, you're stuck with getting more IP addresses and putting a single domain on each IP (which defeats the purpose of name-based virtual hosts), putting the onus back on the client connection (which you said you'd like to avoid), or having a "default" domain with nothing but a simple landing page that has links to specific pages that can be differentiated by name or by a URL rewrite. Which one will give you fewest long-term headaches?

    | improve this answer | |
    • I think that if I could just make a directory: > and have it point to: >/var/www/problemdomain.example.com/foo The landing page can easily have a subdirectory /foo in which I could put whatever to make it happen: > then I'd be home and dry. – Christopher Chirdon May 30 '14 at 19:40
    • Also, right now ... it's nearly always problemdomain.example.com that is the continuing headache. – Christopher Chirdon May 30 '14 at 19:46
    • Would +FollowSymLinks in an .htaccess file and a symlink to the root of the problem directory work? I'm going to try that... – Christopher Chirdon May 30 '14 at 19:50
    • Symlink didn't work. bugger. – Christopher Chirdon May 30 '14 at 20:03

    I don't think that you can do what you want to do automagically. When a client wants to connect to a host it resolves problemdomain.example.com to an IP address. It contacts the server at the IP address. As part of the conversation it passes a Host header

    Host: problemdomain.example.com

    The server uses the Host header to decide how to route the request to the relevant vhost.

    In your case, the request to the resolver fails so the client doesn't know host to contact the server so it can't and erm that's it.

    | improve this answer | |
    • I guess I just hoped that there was a way to clue in the web browser to look for the host at that IP address. – Christopher Chirdon May 30 '14 at 20:05
    • Not really, the client needs an address, if it can't get the address then it can't proceed. – user9517 May 30 '14 at 20:08

    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

    Not the answer you're looking for? Browse other questions tagged or ask your own question.