Feb 15 2015

Redirect Record

Posted by Vitalie Cherpec

We are introducing a new handy peseudo record, the REDIRECT record. This new feature will help you to configure HTTP redirects for your domains/subdomains from the web interface and git.


Sometimes you need to redirect a domain/subdomain to another URL, to achieve this you need a web server which will do the redirects and then you need to point the domains to this server from the DNS.


Now you can use LuaDNS to achieve this in a single step without the overhead of maintaining an external web server. We've implemented a redirection service integrated with your LuaDNS account. To add a HTTP redirect for a domain/subdomain all you need is to add a simple REDIRECT record to your configuration.

How it works

When you add a REDIRECT record the LuaDNS will configure the redirection service and will point the redirected domains/subdomains to it. There are three modes of redirection:

  • Relative redirect - the server issues a 301 redirect, the request path and query string are appended to destination URL
  • Exact redirect - the path and query string is discarded and visitors are redirected to destination URL with 301 status code
  • Frame masking - the destination is loaded in a HTML frame


-- @name   = relative name or '*'
-- @target = target url
-- @mode   = redirect mode (0=relative, 1=exact, 2=frame, default: 0)
-- @ttl    = cache TTL (default: user default TTL)
redirect(name, target, mode, ttl)


-- File: example.com.lua
-- _a variable is set by the system to zone name
-- _a = "example.com"

-- # Relative redirect
-- redirect apex/naked domain to www
-- Example: example.com/foo?q=param -> www.example.com/foo?q=param
redirect(_a, "http://www." .. _a .. "/")

-- # Exact redirect
-- redirect http://mail.example.com/* to http://mail.provider.com/
-- Example: http://mail.example.com/foo?q=param -> http://mail.provider.com/
redirect("webmail", "http://mail.provider.com/", 1)

-- # Frame redirect
-- redirect http://mail.example.com/ to http://www.provider.com/ using a HTML frame
redirect("mail", "http://mail.provider.com/")

Other Changes

  • Improved web interface