$SERVER_ROOT variable in error document

Discussion in 'General' started by closet geek, Oct 19, 2008.

  1. closet geek

    closet geek Well-Known Member

    Hi,

    We are trying to setup a global error document page that all virtual hosts will serve when the error is triggered.

    I tried to put this $SERVER_ROOT/404.html in the error document section of each virtual host but this simply triggers a redirect loop. Why is this variable not available? How do we solve this problem?

    Thanks.
     
  2. mistwang

    mistwang LiteSpeed Staff

    That's because the file "$SERVER_ROOT/404.html" does not exist.
    You need to create the file first, you need to replace $SERVER_ROOT/ with the real server root, then create 404.html there, usually it is /opt/lsws or /usr/local/lsws.
     
  3. closet geek

    closet geek Well-Known Member

    Hmm fair enough, I assumed $SERVER_ROOT would work as it is used in many other places throughout the configuration.

    It still doesn't work however, I have changed the value to /opt/lsws/404.html and the file is definitely there.

    Thanks.
     
  4. mistwang

    mistwang LiteSpeed Staff

    check the file permission of /opt/lsws/404.html.
     
  5. closet geek

    closet geek Well-Known Member

    -rw-r--r-- 1 nobody nobody 4 Oct 19 20:18 404.html

    I've also tried 755 and root as the owner...
     
  6. mistwang

    mistwang LiteSpeed Staff

    It should work.
    What exactly the error you got?
     
  7. closet geek

    closet geek Well-Known Member

    I just get the standard litespeed 404 page. I've turned on debug output, the problem is that litespeed is looking for the file here:

    /home/username/public_html/opt/lsws/404.html not here: /opt/lsws/404.html

    I have ExtApp Chroot Mode set to Same as Server.

    Thanks!
     
  8. mistwang

    mistwang LiteSpeed Staff

    Looks like it has been set to "$DOC_ROOT/opt/lsws/404.html" for some reason.
    How vhosts were configured?
     
  9. closet geek

    closet geek Well-Known Member

    We configured them manually. Which part of the configuration could cause this problem?
     
  10. mistwang

    mistwang LiteSpeed Staff

    OK, I know what is wrong, it is a misunderstanding, when you configure A "Custom Error Page", the path is a URL, not a file path.

    You have to set the error URL to "/404.html", then add a static context, equivalent to "Alias" in Apache, mapping "/404.html" to "/opt/lsws/404.html".
     
  11. closet geek

    closet geek Well-Known Member

    All working now :)
     

Share This Page