Ughh... how do you use the SAME 404 page for every VirtualHost

Discussion in 'Mac OS X Server, Xserve, and Networking' started by maclover001, May 19, 2009.

  1. macrumors 6502a

    maclover001

    Joined:
    Mar 25, 2008
    Location:
    Vancouver, Canada
    #1
    I tried setting the ErrorDocument for 404 in httpd.conf, and leaving the "Error Document" field in Server Admin blank for every virtual host, but that causes Server Admin to complain that the server can't be started because of "Duplicate ErrorDocument arguments".

    If I just paste in the exact http address of the document I want to use into every field, then that causes that URL to actually show instead of the url that the user typed.

    How can I use the exact same 404 document for every virtual host, while keeping the original URL in the address bar?

    Thanks
     
  2. macrumors 6502

    Joined:
    Jul 24, 2008
    #2
    I believe you'd have to make a copy of the 404 error page on each virtual host.
     
  3. thread starter macrumors 6502a

    maclover001

    Joined:
    Mar 25, 2008
    Location:
    Vancouver, Canada
    #3
    Tried that. It worked, but it doesn't show the CSS stylesheet :confused::confused:
     
  4. macrumors 6502

    Joined:
    Jul 24, 2008
    #4
    When you do that, make sure you're copying your stylesheet and modifying the 404 page to reference the stylesheet that's actually in that VirtualHost's directory.
     
  5. thread starter macrumors 6502a

    maclover001

    Joined:
    Mar 25, 2008
    Location:
    Vancouver, Canada
    #5
    I did. Going to the file physically (mydomain.com/errordocs/404.html) works, but actually triggering a 404 causes the stylesheet to not show.
     
  6. macrumors 68040

    iSee

    Joined:
    Oct 25, 2004
    #6
    The client's browser loads the css. I'm guessing the path in 404.html specifies the css file using a url relative to /errordocs/404.html. But from the client's perspective, the page was loaded from the url they typed.

    You'll want to use a relative url that is valid no matter what the original url typed was. e.g., "/errordocs/404.css" might work, depending on how your site(s) are set up.
     
  7. thread starter macrumors 6502a

    maclover001

    Joined:
    Mar 25, 2008
    Location:
    Vancouver, Canada
    #7
    Thanks, I'll try it.
     

Share This Page