WwwRedirect (www_redirect v0.1.1)

View Source

Redirects an HTTP request from WWW to Non-WWW and vice versa.

Heavily inspired by: https://stackoverflow.com/a/36509559

Options

  • :to - Specifies the redirect target. Can be :www or :non_www (default).
    • :www - Redirects bare domains to www versions (e.g., example.com -> www.example.com)
    • :non_www (default) - Redirects www domains to bare versions (e.g., www.example.com -> example.com)

Examples

# Redirect to non-www
plug WwwRedirect
plug WwwRedirect, to: :non_www

# Redirect to www
plug WwwRedirect, to: :www

Summary

Functions

call(conn, opts)

init(opts)