Welcome! Log In Create A New Profile

Advanced

Re: How to make a redirect via programming?

Maxim Dounin
May 26, 2011 04:04AM
Hello!

On Wed, May 25, 2011 at 06:41:46PM -0400, speedfirst wrote:

> Hey, I'm making a custom module and need to send back the redirect
> response to the client. It should behave like the "sendRedirect" in java
> servlet programming. So which function is that API?
>
> Thanks.

r->headers_out.location = ngx_palloc(r->pool, sizeof(ngx_table_elt_t));
if (r->headers_out.location == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}

r->headers_out.location->value.len = sizeof("http://example.com/") - 1;
r->headers_out.location->value.data = "http://example.com/";

return NGX_HTTP_MOVED_PERMANENTLY;

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

How to make a redirect via programming?

speedfirst May 25, 2011 06:41PM

Re: How to make a redirect via programming?

speedfirst May 25, 2011 07:14PM

Re: How to make a redirect via programming?

Maxim Dounin May 26, 2011 04:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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