HTTP Redirects

To redirect an HTTP request to another URL you can use the redirect=<code> option. The code is the HTTP status code used for the redirect response and must be between 300-399 for the route to be valid.

# redirect /path to
route add svc /path opts "redirect=301"

To use the redirect with the urlprefix- tags you need to specify the target URL in after the code since the target of the request is usually the address of the service that registers the tag.

urlprefix-/path redirect=301,

If you want to include the original request URI in the redirect target append the $path pseudo-variable to the target URL.

urlprefix-/path redirect=303,$path

To redirect from HTTP to HTTPS you must include the host:port of the HTTP endpoint:

route add svc opts "redirect=301"