Force redirection from HTTP to HTTPS

How to setup force requests redirection from http to https?

http://www.domain.com/somethinghttps://www.domain.com/something

@mangapolska ,

If you are using the CDN-as-Code approach, you can create a rule to match by scheme and redirect the request to https:

import { Router } from '@edgio/core/router';

export default new Router()
  .match(
    { scheme: "HTTP" },
    {
      comment: "redirect http requests to https",
      url: {
        url_redirect: { source: "(.*)", destination: "https://$1", code: 302 },
      },
    }
  )

If using the Rules UI, that may look something like this:

Screenshot

Not working. Incorrect Location: https:///.

Apologies for the late reply. I had mistakenly left out the %{host} feature variable.

export default new Router()
  .match(
    { scheme: "HTTP" },
    {
      url: {
        url_redirect: {
          code: 302,
          destination: "https://%{host}%{request_uri}",
        },
      },
    }
  )