Equivalent to map $status status_title status_desc
March 20, 2023 11:47AM
Hey everyone!

I've been searching for a while for a way to have a map with the response code ("$status" variable) and a title and a description as values, so that I can have a map with all reponse codes (400, 401, [..], 500, 501, etc) and use it in a static page (with SSI active) where I would do something like:

<h1><!--# echo var="status" default="" --> <!--# echo var="st
atus_title" default="Something is wrong" --></h1>
<p align="center"><!--# echo var=""status_desc" default="" --></p>

Currently I have two maps, as follows:

map $status $status_title {
400 'Bad Request';
401 'Unauthorized';

map $status $status_desc {
400 'The server cannot or will not process the request due to something that is perceived to be a client error.';
401 'The client must authenticate itself to get the requested response.';

This is not working, although I get no error when checking the syntax with "nginx -t". How could I combine these two maps into one so that I could get a custom error code, error title and error description in my error page?

Thanks in advance.

Ubi sapientas ibi libertas
Re: Equivalent to map $status status_title status_desc
March 20, 2023 12:15PM
Nevermind, the issue was not in the maps, but in a syntax error in the HTML template. The line:

<p align="center"><!--# echo var=""status_desc" default="" --></p>

Should read:

<p align="center"><!--# echo var="status_desc" default="" --></p>

It's now working as intended. I'll leave this for future reference.

Ubi sapientas ibi libertas
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 72
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready