9951 explained code solutions for 126 technologies


nginx-luaHow to do 301 redirect


Want to do 302 redirect?

server {
  location / {
    content_by_lua_block {
      return ngx.redirect("/new_page.html", 301)
    }
  }
}ctrl + c
content_by_lua_block

nginx-lua module directive to specify block of Lua code

ngx.redirect

redirect to other page

/new_page.html

URL to redirect to

301

status code to use for redirect