# Redirect HTTP to HTTPS

- Check 09.03 · Security and infrastructure · Critical
- Source: https://checklist-seo-geo.com/en/security-infrastructure/redirect-http-https
- Redirect each HTTP URL to its HTTPS equivalent with a single 301, without loops behind a proxy, on Apache, Nginx, Cloudflare, AWS, Plesk, cPanel or WordPress.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/security-infrastructure/redirect-http-https.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

Once HTTPS is in place, the HTTP version of the site must stop responding: each `http://` URL returns a permanent redirect (301 or 308) to the same URL on `https://`, path and parameters included, in a single hop. The expected result: no page responds with 200 over HTTP any more, and old links, bookmarks and crawlers land directly on the right address.

## Why it matters

Installing a certificate is not enough. As long as `http://example.com/contact/` responds with 200, the site exists in two copies: visitors who type the address without the protocol, old links and bookmarks stay on the unencrypted version, and search engines see two URLs for each page.

Google treats the switch from HTTP to HTTPS as a site move. Its documentation recommends permanent server-side redirects, `301` or `308`, which do not cause any loss of PageRank, and advises keeping them for as long as possible, generally at least one year. The Search Console Change of Address tool is not needed for a protocol change: the redirect is the signal.

The redirect is also the prerequisite for HSTS (HTTP Strict Transport Security): a browser only records the HSTS instruction from an HTTPS response, and the browsers' preload list requires a redirect from HTTP to HTTPS on the same hostname.

## What it improves

- **Indexing**: a single version of each page; the signals from links pointing to HTTP are passed to HTTPS.
- **Security**: no more unencrypted browsing after the first click.
- **Experience**: no “Not secure” warning or Chrome confirmation screen for visitors arriving through an old link.
- **Measurement**: a single protocol in the analytics.
- **Generative engines**: a single stable URL to cite. Indirect effect, not measurable on its own.
- **Rankings**: no direct effect; the redirect mainly prevents dilution between two versions.

## How to check

Test a deep page with parameters, without following the redirect:

```bash
curl -s -o /dev/null -w "%{http_code} %{redirect_url}\n" "http://www.example.com/blog/article/?utm_source=test"
```

Compliant result:

```txt
301 https://www.example.com/blog/article/?utm_source=test
```

`308` is also compliant. `302` or `307` are temporary redirects: fix them. `200` means no redirect is in place.

Follow the whole chain to spot unnecessary hops:

```bash
curl -sIL "http://example.com/blog/article/" | grep -i -E "^(HTTP|location)"
```

Only one `location` should appear before the `200` response. Two hops (`http://example.com` → `https://example.com` → `https://www.example.com`) form a chain to fix: see [standardize HTTP/HTTPS and www/non-www](https://checklist-seo-geo.com/en/indexing-canonicalization/standardize-http-https-www-non-www).

Also test a static file (`/robots.txt`, an image, a PDF) and the sitemap: some rules only apply to pages handled by the CMS.

At scale, crawl the list of URLs from the old `http://` sitemap with Screaming Frog (List mode): all of them must respond with a 301 to their exact equivalent.

> **Tip:** test with curl rather than with your browser. If HSTS is already active or if Chrome forces HTTPS, the browser never contacts the HTTP version and shows an internal `307` redirect that does not reflect the server configuration.

## How to implement

### Before you start

- **The certificate first**: HTTPS must work on every redirected name. See [use HTTPS everywhere](https://checklist-seo-geo.com/en/security-infrastructure/use-https-everywhere).
- **Only one layer redirects**: the CDN if there is one, otherwise the web server. Not the CDN, the server and a CMS plugin at the same time, which produce chains and loops.
- **A single hop to the final URL**: if you also choose `www` or the bare domain, combine both rules into one direct redirect.
- **Path and parameters preserved**: never redirect all of HTTP to the home page.
- **301 or 308**: both are permanent for Google. `308` preserves the method: a `POST` request sent over HTTP remains a `POST` after the redirect, whereas a `301` often turns it into a `GET`. Useful for an API or an old form.
- **After the redirect**: switch canonicals, the sitemap, internal links and structured data to `https://`. A redirect makes up for an internal link on HTTP, but each click costs a round trip.

Let's Encrypt HTTP validation (`/.well-known/acme-challenge/`) follows redirects to HTTPS: there is no need to exclude it from the rule.

### Apache

Versions: Apache 2.4.

In the port 80 virtual host, the simplest and fastest method:

```apache
<VirtualHost *:80>
    ServerName www.example.com
    ServerAlias example.com
    Redirect permanent / https://www.example.com/
</VirtualHost>
```

`Redirect` preserves the path and the query string. To keep the requested name instead of enforcing `www`, use this instead:

```apache
<VirtualHost *:80>
    ServerName www.example.com
    ServerAlias example.com
    RewriteEngine On
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</VirtualHost>
```

Without access to the configuration, in the `.htaccess` file at the root, before the CMS rules:

```apache
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
```

The second condition prevents a loop behind a CDN or load balancer that terminates HTTPS and contacts Apache over HTTP. Reload with `sudo apachectl configtest && sudo systemctl reload apache2`.

### Nginx

Versions: Nginx 1.18 and later.

A block dedicated to port 80, in `/etc/nginx/sites-available/example.com`:

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

`$request_uri` contains the path and the parameters. To keep the requested name, write `return 301 https://$host$request_uri;`. Behind a load balancer that terminates HTTPS and forwards everything over HTTP, redirect based on the forwarded header:

```nginx
if ($http_x_forwarded_proto = "http") {
    return 301 https://$host$request_uri;
}
```

Reload with `sudo nginx -t && sudo systemctl reload nginx`.

### LiteSpeed

Versions: LiteSpeed Web Server 6.x, OpenLiteSpeed 1.7 and 1.8.

LiteSpeed reads `.htaccess`: the block from the Apache section works as is. On OpenLiteSpeed, enable rewriting and `.htaccess` reading in the virtual host, or put the rule in the virtual host's `Rewrite` tab, then do a graceful restart.

### Caddy

Versions: Caddy 2.

Automatic: Caddy redirects HTTP to HTTPS for every name it serves over HTTPS. Nothing to add.

### IIS

Versions: IIS 10 (Windows Server 2016 to 2025), URL Rewrite module 2.1.

On IIS 10 version 1709 and later, native HSTS support includes a redirect attribute. Otherwise, install the URL Rewrite module and add the following to `web.config`:

```xml
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="HTTP to HTTPS" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="off" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>
```

The query string is appended by default. The site must have an `http` binding on port 80 in addition to the `https` binding.

### Cloudflare

Versions: Cloudflare dashboard, all plans, November 2026.

Do the redirect at the edge, and remove it from the origin if it already exists there:

1. In [`SSL/TLS > Overview`](https://dash.cloudflare.com/?to=/:account/:zone/ssl-tls), check the encryption mode. By default, automatic mode picks the most secure mode the origin accepts; to set it yourself, switch to custom mode and choose “Full (strict)”. In “Flexible” mode, Cloudflare contacts the origin over HTTP: if the origin redirects to HTTPS, the loop is immediate (`ERR_TOO_MANY_REDIRECTS`).
2. In [`SSL/TLS > Edge Certificates`](https://dash.cloudflare.com/?to=/:account/:zone/ssl-tls/edge-certificates), enable “Always Use HTTPS”. All HTTP requests to proxied names are redirected to HTTPS.
3. To combine this with the choice of `www` in a single hop, use a redirect rule from the [rules overview](https://dash.cloudflare.com/?to=/:account/:zone/rules/overview) instead: see [standardize HTTP/HTTPS and www/non-www](https://checklist-seo-geo.com/en/indexing-canonicalization/standardize-http-https-www-non-www).

A “DNS only” name (gray cloud) is not affected: its redirect must be done on the server.

### AWS

Versions: CloudFront, Application Load Balancer, S3 and Amplify Hosting, AWS console, November 2026.

- **CloudFront**: on the `Behaviors` tab, edit each behavior and set “Viewer protocol policy” to “Redirect HTTP to HTTPS” (301 status code). Do this for every behavior, not just the default one.
- **Application Load Balancer**: edit the HTTP:80 listener, default action “Redirect to URL”, protocol `HTTPS`, port `443`, status code `HTTP_301`. The host, path and parameters are preserved by default (`#{host}`, `#{path}`, `#{query}`).
- **S3**: an S3 static website cannot redirect to HTTPS. Put CloudFront in front of it.
- **Amplify Hosting**: automatic redirect.

### Google Cloud

Versions: external Application Load Balancer, Firebase Hosting, Google Cloud console, November 2026.

On an external Application Load Balancer, create a dedicated URL map that redirects to HTTPS (HTTPS redirect with the `MOVED_PERMANENTLY_DEFAULT` code, i.e. 301), attached to a target HTTP proxy and to a forwarding rule on port 80. Firebase Hosting, and Cloud Run behind Firebase, redirect automatically.

### Azure

Versions: App Service and Azure Front Door (Standard and Premium), Azure portal, November 2026.

On App Service, enable “HTTPS Only” in the app's configuration. On Azure Front Door, tick “Redirect all traffic to use HTTPS” in the route; the route must accept both HTTP and HTTPS protocols for the redirect to apply.

### Plesk

Versions: Plesk Obsidian 18.0, SSL It! extension.

In `Websites & Domains > your domain > SSL/TLS Certificates` (SSL It!), enable “Redirect from HTTP to HTTPS”: Plesk sets up a 301 redirect. The option is enabled by default on new Plesk Obsidian installations. Do not add a rule in `.htaccess` or a WordPress plugin on top of it: you would create a double redirect.

### cPanel

Versions: cPanel & WHM 130 and later, Jupiter theme.

In `Domains > Domains` ([cPanel documentation](https://docs.cpanel.net/cpanel/domains/domains/)), enable “Force HTTPS Redirect” on each domain. The option stays grayed out as long as no valid certificate covers the domain: run AutoSSL in `Security > SSL/TLS Status`. If you prefer the `.htaccess` block from the Apache section, for example to combine it with the choice of `www`, leave this option disabled.

### Shared hosting

Most hosts offer a “Force HTTPS” checkbox in the domain or certificate management. Failing that, paste the `.htaccess` block from the Apache section at the top of the file at the site root. Then test with curl: a panel option and an `.htaccess` rule active at the same time often produce two hops.

### Vercel

Versions: Vercel platform, all plans, November 2026.

Automatic and cannot be disabled: Vercel redirects HTTP to HTTPS with a 308 status code.

### Netlify

Versions: Netlify platform, all plans, November 2026.

Automatic as soon as the domain's certificate is active: check with curl that the HTTP version returns a permanent redirect.

### WordPress

Versions: WordPress 6.4 to 7.1.

1. Do the redirect at the server or CDN level (previous sections), not with a plugin: it is faster and also covers static files.
2. Switch the WordPress Address and the Site Address to `https://` in `Settings > General`, or with the button offered by `Tools > Site Health` when HTTPS is detected. Without this change, WordPress itself sends visitors back to HTTP and creates a loop.
3. Behind a proxy, add to `wp-config.php` the `X-Forwarded-Proto` detection described in [use HTTPS everywhere](https://checklist-seo-geo.com/en/security-infrastructure/use-https-everywhere).
4. If a security or SSL plugin also offers the redirect, disable that option when the server already handles it.

### Shopify

Versions: Shopify, all plans, November 2026; also applies to Wix, Squarespace and Webflow.

Automatic: visitors arriving over HTTP are redirected to the encrypted store. Wix, Squarespace and Webflow also redirect automatically.

### Laravel

Versions: Laravel 10 to 13.

Let the web server or the platform redirect. A redirect in a PHP middleware does not cover static files and adds the application boot to every HTTP request. On the application side, declare the trusted proxies so that Laravel knows the original request was over HTTPS and generates correct URLs. On Laravel Forge, the certificate and the redirect are configured from the site.

#### Laravel 11 to 13

In `bootstrap/app.php`:

```php
->withMiddleware(function (Middleware $middleware): void {
    $middleware->trustProxies(at: '*');
})
```

#### Laravel 10

In `app/Http/Middleware/TrustProxies.php`:

```php
protected $proxies = '*';
```

### Next.js

Versions: Next.js 15 and 16.

`next start` does not redirect to HTTPS: the redirect belongs to the platform or to the reverse proxy placed in front of it (Nginx, Caddy, load balancer). Do not code a protocol redirect in `next.config.js` (or `next.config.ts`) or in `proxy.ts` (`middleware.ts` up to Next.js 15): behind a proxy that terminates HTTPS, the request Next.js receives is over HTTP and the rule loops.

## Common mistakes

- **302 or 307 redirect** instead of 301 or 308: the signal sent to search engines is temporary.
- **Sending everything to the home page**: each page loses its equivalent and deep external links are worth nothing any more.
- **Loop behind a proxy**: the server sees an HTTP request coming from the CDN and redirects endlessly. Test `X-Forwarded-Proto` or switch Cloudflare to “Full (strict)”.
- **Two hops**: HTTP to HTTPS, then non-`www` to `www`. Combine them into a single rule.
- **JavaScript or meta refresh redirect**: slow, ignored by some clients and invisible to HTTP tools. It must be done server-side.
- **Removing the redirect after a few months**: old HTTP links and bookmarks exist forever. Keep it.
- **Sitemap and canonicals still on `http://`**: Google receives contradictory signals and crawls redirects for nothing.
- **Enabling HSTS before testing**: in case of an error, visitors stay blocked for the full duration of the instruction.

## Frequently asked questions

### Should I use a 301 or a 308 redirect to switch to HTTPS?

Both work: Google treats 301 and 308 redirects as permanent and they do not cause any loss of PageRank. The 301 is the most widespread and supported by every tool. The 308 also guarantees that the method is preserved, which matters for an API or a form sent via POST to an old HTTP address. Just avoid the temporary 302 and 307 redirects.

### How long should the HTTP to HTTPS redirect be kept?

Keep it indefinitely. Google advises keeping the redirects of a site move for as long as possible, at least one year, but external links, bookmarks and old documents pointing to HTTP will never disappear. An HTTP to HTTPS redirect costs the server almost nothing, and removing it would bring back an unencrypted version of the site, duplicating the HTTPS version.

### Should I use the Search Console Change of Address tool to switch to HTTPS?

No. Google states that the Change of Address tool is not needed for a switch from HTTP to HTTPS, nor for a change between www and non-www on the same domain. Page-to-page 301 redirects, an HTTPS sitemap and consistent canonicals are enough. A domain property in Search Console also covers both protocols at once.

### Why does my site show “too many redirects” after switching to HTTPS?

The most common cause is a proxy or CDN that contacts the server over HTTP: the server believes the request is unencrypted and redirects it again, endlessly. On Cloudflare, set the encryption to Full (strict) mode. On the server, test the X-Forwarded-Proto header before redirecting. Also check that only one layer redirects, and that the CMS address is on HTTPS.

## Resources

- [Google Search Central: Redirects and Google Search](https://developers.google.com/search/docs/crawling-indexing/301-redirects?hl=en)
- [Google Search Central: Site moves with URL changes](https://developers.google.com/search/docs/crawling-indexing/site-move-with-url-changes?hl=en)
- [Apache: redirecting to HTTPS](https://httpd.apache.org/docs/2.4/rewrite/avoid.html#redirect)
- [Nginx: return directive](https://nginx.org/en/docs/http/ngx_http_rewrite_module.html#return)
- [Cloudflare: Always Use HTTPS](https://developers.cloudflare.com/ssl/edge-certificates/additional-options/always-use-https/)
- [Amazon CloudFront: Require HTTPS between viewers and CloudFront](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-https-viewers-to-cloudfront.html)
- [Vercel: encryption and HTTPS redirect](https://vercel.com/docs/cdn-security/encryption)

Next steps: [fix mixed content](https://checklist-seo-geo.com/en/security-infrastructure/fix-mixed-content), [configure HSTS if appropriate](https://checklist-seo-geo.com/en/security-infrastructure/configure-hsts-if-appropriate) and [fix redirect chains](https://checklist-seo-geo.com/en/http-redirects/fix-redirect-chains).
