Welcome! Log In Create A New Profile

Advanced

Re: error_page can not work in if directive

December 25, 2012 11:47AM
thanks, but a new question comming。
I try to resolve my problem according to your method:
(1)
“set" is also an location-level rewrite module directive, so the conf like this
location / {
root XXX;
set $var "haha";
error_page 413 /413.${var}.html;
}

will return 404, but 413.haha.html exists my root dir。I see the debug log , find some log like
http finalize request: 404, "/413..html?"
obviously, nginx takes $var as an empty string, I think the reason is also that 413 error is generated before set directive? so , how to use variable in error_page uri?

(2)
if I writer conf like this:
location / {
set $var "haha";
error_page 413 /413.html;
}

location = /413.html {
if ($var) {
rewriter ^ /413.new.html;
}
}

the key problem is how can i pass the $var to location /413.html? I try it , the second $var is empty(I also wonder about the result because I remember when internal redirect, the location can share the variable) 。

Thank you .
Subject Author Posted

error_page can not work in if directive

xinghua_hi December 25, 2012 08:06AM

Re: error_page can not work in if directive

xinghua_hi December 25, 2012 09:36AM

Re: error_page can not work in if directive

Maxim Dounin December 25, 2012 09:44AM

Re: error_page can not work in if directive

xinghua_hi December 25, 2012 10:09AM

Re: error_page can not work in if directive

Maxim Dounin December 25, 2012 10:28AM

Re: error_page can not work in if directive

xinghua_hi December 25, 2012 11:47AM

Re: error_page can not work in if directive

Maxim Dounin December 25, 2012 12:26PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 255
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