H2O

the optimized HTTP/1.x, HTTP/2 server
Powered by Oktavia

Configure > Redirect Directives

This document describes the configuration directives of the redirect handler.

"redirect"

Description:

Redirects the requests to given URL.

If the argument is a scalar, the value is considered as the URL to where the requests should be redirected. If the argument is a mapping, the url property is considered the URL, and the status property indicates the status code to be used for the redirect response.

The directive rewrites the URL by replacing the host and path part of the URL at which the directive is used with the given URL. For example, when using the configuration below, requests to http://example.com/abc.html will be redirected to https://example.com/abc.html.

Example. Redirect all HTTP to HTTPS permanently (except for the files under RSS)
hosts:
    "example.com:80":
        paths:
            "/":
                redirect:
                    status: 301
                    url:    "https://example.com/"
            "/rss":
                file.dir: /path/to/rss
Level:
path