$SERVER_ROOT variable in error document

closet geek

Well-Known Member
#1
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.
 

mistwang

LiteSpeed Staff
#2
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.
 

closet geek

Well-Known Member
#3
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.
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.
 

closet geek

Well-Known Member
#7
It should work.
What exactly the error you got?
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!
 

mistwang

LiteSpeed Staff
#10
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".
 
Top