﻿<head><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4357510538660394"
     crossorigin="anonymous"></script></head>URL: /rules/security/http-to-https

---
title: "HTTP to HTTPS redirect: how squirrel probes for it"
description: "squirrel requests the http:// version of a sample of your URLs and reports the ones that answer over plain HTTP without redirecting to HTTPS."
---

## What an HTTP to HTTPS redirect is

An HTTP to HTTPS redirect is a response on port 80 that sends the client to the `https://` form of the same URL. It exists because links, bookmarks and typed addresses still arrive over plain HTTP, and without a redirect they either fail or serve a duplicate copy of the site on an insecure origin.

Search engines treat `http://example.com/page` and `https://example.com/page` as separate URLs. A permanent redirect consolidates them and keeps the HTTPS version as the indexed one. HSTS eventually removes the need for the redirect in browsers that have already seen the header, but the redirect is what handles the first visit and every non-browser client.

## What squirrel checks

The rule is site-wide and makes live network requests. It builds a sample of same-hostname URLs starting with the base URL, adds crawled pages whose status code is under 400 until the sample limit is reached, rewrites each to `http://` and follows the redirect chain. It emits a single check named `http-to-https`:

- Skipped when there is no base URL. Message: `No base URL available`.
- Skipped when the base URL does not parse. Message: `Invalid base URL`.
- Skipped when the base URL is not HTTPS. Message: `Base URL is not HTTPS`.
- Fail when at least one probed URL answers over plain HTTP and never reaches HTTPS. Message: `3 HTTP URL(s) do not redirect to HTTPS (20 of 20 URL(s) probed)`, with each entry labelled `http://example.com/page answered 200 over HTTP without redirecting to HTTPS`.
- Pass when every probed URL redirects to HTTPS. Message: `20 sampled HTTP URL(s) redirect to HTTPS`.
- Info when nothing could be verified (no listener on port 80, errors, rate limiting) or the run was partial and found no failure. A URL that cannot be reached over HTTP at all gets no verdict and is not a finding.

Probes run five at a time with a 100 ms stagger, each hop times out after 10 seconds and chains stop at 10 hops. Each probe is one `HEAD` request without retries, sent with the same user agent and headers as the crawl. A total budget (default 20 seconds, `probeBudgetMs`) stops workers picking up new URLs; probes already in flight are still awaited. When the budget runs out the check says so: the message reads `partial coverage` with the number of URLs not probed, and `details.partial` is `true`, so a slow host is never reported as clean. Raise `probeBudgetMs` or lower `sampleLimit` to cover the whole sample. Redirect loops get no verdict. A redirect to a scheme other than `http` or `https`, to a link-local or cloud metadata address such as `169.254.169.254`, or to another host whose DNS answers include one (or whose lookup fails) is not followed: the chain stops at that redirect. With `--offline`, a redirect to another host is not followed either. On the CLI, with the site's own hostnames checked (see [`follow_redirects`](/configuration/crawler#follow_redirects)), every probe and hop connects to the address its name was checked on, and a host that resolves to a link-local or cloud metadata address gets no request: that URL gets no verdict.

`squirrel analyze` re-runs rules over the stored crawl and makes no live request, so there this rule is a skipped check with `skipReason` `analyze-offline`, the value `not-checked` and the message `analyze runs offline; run `squirrel audit` to probe`. It is listed under `notChecked` with outcome `coverage_gap`, so a finding of it stays open. Run `squirrel audit` to probe.

On a local or private-network host, such as `localhost` or `192.168.1.10`, the rule is skipped and left out of the score, because a dev server is not the production edge. See [Transport and delivery rules do not apply](/guides/local-audits-cli#transport-and-delivery-rules-do-not-apply).

## How to fix it

```nginx
server {
  listen 80;
  server_name example.com www.example.com;
  return 301 https://example.com$request_uri;
}
```

Redirect in one hop, preserving the path and query string, and use 301 rather than 302 so the target is the canonical URL. Chaining HTTP to HTTPS to a canonical host costs a round trip on every first visit.

| | |
|---|---|
| **Rule ID** | `security/http-to-https` |
| **Category** | [Security](/rules/security) |
| **Scope** | Site-wide |
| **Severity** | warning |
| **Weight** | 3/10 |

## Options

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `sampleLimit` | integer, 1 to 100 | `20` | Maximum number of pages to probe for HTTP to HTTPS redirects |
| `probeBudgetMs` | integer, 1000 to 600000 | `20000` | Total time budget for all probes, in milliseconds. When it runs out the rule reports partial coverage |

### Configuration example

```toml squirrel.toml
[rule_options."security/http-to-https"]
sampleLimit = 40
probeBudgetMs = 60000
```

## Enable / disable

### Disable this rule

```toml squirrel.toml
[rules]
disable = ["security/http-to-https"]
```

### Disable all Security rules

```toml squirrel.toml
[rules]
disable = ["security/*"]
```

### Enable only this rule

```toml squirrel.toml
[rules]
enable = ["security/http-to-https"]
```

`enable` replaces the default `["*"]`, so this is the only rule selected. Leave `disable` out: a rule that matches any `disable` pattern is skipped even when `enable` names it. Only an `enabled` setting under a rule's own `[rule_options]` table overrides both lists.

## Check names by outcome

Each check name this rule can emit, by what it means to a tool comparing two audits. A **problem** check is a finding. A **clean** check says the rule ran over what it covers and found nothing; it clears the problem checks listed beside it, so a finding is fixed when the rule ran over the same scope and a clean check took its place. A **not checked** check says the rule did not evaluate, and never clears a finding.

{/* rule-checks:start */}

| Check name | Outcome | Clears |
| --- | --- | --- |
| `http-to-https` | Problem |  |
| `http-to-https` | Clean | `http-to-https` |
| `http-to-https` | Not checked |  |

{/* rule-checks:end */}

## Related rules

- [security/https](/rules/security/https): the pages themselves, checked without any network probe.
- [security/hsts](/rules/security/hsts): the header that lets browsers skip the redirect entirely.
- [crawl/redirect-chain](/rules/crawl/redirect-chain): multi-hop chains, including the ones this redirect can create.
- [links/https-downgrade](/rules/links/https-downgrade): internal links that make the browser take the redirect on every click.

Security findings ship in every audit next to the SEO, performance and agent experience rules. See [Website security scan with AI](https://squirrelscan.com/learn/audit-website-security-with-ai) for how an agent works through a report.

{/* glossary:backlinks:start */}

Glossary: [HTTPS](/glossary/https).

{/* glossary:backlinks:end */}

## References

- [Redirections in HTTP, MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Redirections)
- [301 redirects and Google Search, Google Search Central](https://developers.google.com/search/docs/crawling-indexing/301-redirects)

## Check your site

Run `squirrel audit https://nutshop.squirrelscan.com` and open the Security section of the report. Each HTTP URL that does not redirect is listed with its status code. Signed-out local audits need no account and cost nothing. Signed-in audits spend credits.

<CardGroup cols={2}>
  <Card title="Install squirrel" icon="terminal" href="/quickstart">
    One command to install, one to run your first audit.
  </Card>
  <Card title="See a samp