# Fix mixed content

- Check 09.04 · Security and infrastructure · Critical
- Source: https://checklist-seo-geo.com/en/security-infrastructure/fix-mixed-content
- Find the resources loaded over HTTP on your HTTPS pages and fix them at the source, in the database, theme or CDN, on WordPress, Shopify, Laravel or Next.js.
- 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/fix-mixed-content.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

Mixed content refers to a page served over HTTPS that loads a resource over HTTP: an image, script, stylesheet, font, iframe or `fetch` request. This check consists of finding each of these resources and switching it to `https://` at the source: database, templates, CSS and JavaScript files, third-party scripts. Once it is done, the browser console no longer shows any mixed content warning and every page displays a padlock without reservation.

## Why it matters

A resource loaded over HTTP can be read and modified along the way. For a script or a stylesheet, this amounts to letting any intermediary rewrite the page. Browsers respond in two ways:

- **“Upgradable” content**: images (`<img src>`), audio and video. The browser automatically rewrites the URL to `https://`. If the resource does not exist over HTTPS, it does not display.
- **Blockable content**: scripts, stylesheets, iframes, fonts, `fetch` and `XMLHttpRequest` requests, images in `srcset` or in `<picture>`, images in CSS via `url()`. The browser simply blocks them.

In practice, a page with mixed content displays without styling, loses a module (map, video, form, reviews widget), or breaks an analytics or payment script. And a resource blocked for the visitor is also blocked for Googlebot during rendering: content injected by a script loaded over HTTP does not appear in the rendered HTML that Google indexes. The Search Console HTTPS report does not detect mixed content; you have to look for it yourself.

## What it improves

- **Display and functionality**: styles, scripts, fonts and iframes load again.
- **Rendering by search engines**: content added by JavaScript is present in the page rendered by Googlebot.
- **Trust**: no more warning icon in the address bar on some browsers.
- **Security**: no resource can be modified in transit any more.
- **Prerequisite for HSTS** and for a strict CSP policy.
- **Rankings**: no direct effect; the effect comes through rendering and experience.

## How to check

**On a page**: open the developer tools (F12), Console tab, and reload. Each faulty resource produces a message of the form `Mixed Content: The page at 'https://…' was loaded over HTTPS, but requested an insecure …`, which states whether the resource was automatically upgraded or blocked. The console is cleared on each navigation: test each template (home, category, article, product page, cart, form).

**In the source code**, look for hard-coded URLs:

```bash
curl -s https://www.example.com/ | grep -o -E '(src|href|action|srcset|content)="http://[^"]+"' | sort -u
curl -s https://www.example.com/wp-content/themes/montheme/style.css | grep -o -E "url\(['\"]?http://[^)]+" | sort -u
```

`<a href="http://…">` links to other sites are not mixed content, but those to your own domain cause an unnecessary redirect: fix them too.

**Across the whole site**: Screaming Frog, `Security` tab, `Mixed Content` filter, lists the HTTPS pages that load HTTP resources, provided you enable JavaScript rendering for resources added by scripts. The web.dev documentation also mentions dedicated crawlers such as Mixed Content Scan.

**In production, on real visits**: send the `Content-Security-Policy-Report-Only` header with a reporting directive. Browsers report insecure resources without blocking anything:

```txt
Content-Security-Policy-Report-Only: default-src https: 'unsafe-inline' 'unsafe-eval' data: blob:; report-uri https://example.com/csp-rapports
```

## How to implement

### Before you start

The order of fixes:

1. **Your own resources**: replace `http://www.example.com/…` with `https://www.example.com/…` or with a root-relative path (`/images/logo.png`). Avoid protocol-relative URLs (`//example.com/…`), which are no longer useful.
2. **Third-party resources available over HTTPS**: test the `https://` URL in the browser; if it responds, replace it.
3. **Third-party resources without HTTPS**: host them yourself if the license allows it, change provider, or remove them.
4. **Safety net**: the `Content-Security-Policy: upgrade-insecure-requests` header asks the browser to rewrite all requests to HTTPS, including blockable content. A resource that is unavailable over HTTPS then fails instead of loading unencrypted. Keep it as a complement, not as a replacement for the fixes: it does not fix the code, the links, or the clients that do not apply it.

> **Warning:** back up the database before any search and replace. A poorly targeted replacement in serialized data (WordPress, PrestaShop) can break settings or widgets.

### Apache

Versions: Apache 2.4.

Add the safety net in the HTTPS virtual host or in `.htaccess`:

```apache
<IfModule mod_headers.c>
    Header always set Content-Security-Policy "upgrade-insecure-requests"
</IfModule>
```

If you already have a `Content-Security-Policy` header, add the `upgrade-insecure-requests;` directive to its value rather than creating a second header. Reload with `sudo apachectl configtest && sudo systemctl reload apache2`.

### Nginx

Versions: Nginx 1.18 and later; add_header_inherit directive from Nginx 1.29.3.

In the HTTPS `server` block:

```nginx
add_header Content-Security-Policy "upgrade-insecure-requests" always;
```

An `add_header` in a `location` block cancels those inherited from the `server` block: repeat the line in the `location` blocks that define their own headers. Reload with `sudo nginx -t && sudo systemctl reload nginx`.

### Cloudflare

Versions: Cloudflare dashboard, all plans, November 2026.

In [`SSL/TLS > Edge Certificates`](https://dash.cloudflare.com/?to=/:account/:zone/ssl-tls/edge-certificates), enable “Automatic HTTPS Rewrites”. Cloudflare rewrites in the HTML the `http://` URLs of resources it knows to be available over HTTPS. Documented limitations: resources loaded later by JavaScript or CSS are not rewritten, and for domains missing from its reference lists, only active content is. It is a stopgap: fix the source.

To add `upgrade-insecure-requests` without touching the server: from the [rules overview](https://dash.cloudflare.com/?to=/:account/:zone/rules/overview), `Create rule > Response Header Transform Rule`, “Set static” operation, `Content-Security-Policy` header, value `upgrade-insecure-requests`.

### AWS

Versions: AWS console, Amazon CloudFront and Amazon S3, November 2026.

On CloudFront, add the `Content-Security-Policy: upgrade-insecure-requests` header through a custom response headers policy (`Policies > Response headers > Create response headers policy`, security headers section, Content-Security-Policy), then attach it to the behavior. Files served from S3 (CSS, JavaScript) are fixed in the repository, then with a new upload and a CloudFront invalidation.

### Plesk

Versions: Plesk Obsidian 18.0.

Fix the CMS (WordPress and following sections). For the safety net, add the line from the Nginx section in `Websites & Domains > your domain > Apache & nginx Settings`, “Additional nginx directives” field, or the Apache block in `.htaccess`.

### cPanel

Versions: cPanel & WHM 124 and later.

File Manager (`Files > File Manager`) lets you edit `.htaccess` (block from the Apache section) and the theme files. For the database, phpMyAdmin (`Databases > phpMyAdmin`) offers a search across all tables: search for `http://www.example.com` to measure the extent before replacing with the tool suited to your CMS.

### Shared hosting

Same method: `.htaccess` for the safety net, the CMS tool for the database. Without command-line access, export the database from the panel and search for the URLs in the file:

```bash
grep -o "http://www\.example\.com[^\"' <)]*" sauvegarde.sql | sort | uniq -c | sort -rn | head -50
```

### WordPress

Versions: WordPress 6.4 and later; WP-CLI 2; Better Search Replace 1.4; Really Simple Security 9.

1. **Site addresses**: `Settings > General`, WordPress Address and Site Address on `https://`. Since WordPress 5.7, the button in `Tools > Site Health` updates them and rewrites the site's HTTP URLs in the content on the fly, under certain conditions (notably identical WordPress Address and Site Address).
2. **Database**, with WP-CLI, as a dry run and then for real:

```bash
wp search-replace 'http://www.example.com' 'https://www.example.com' --all-tables-with-prefix --skip-columns=guid --dry-run
wp search-replace 'http://www.example.com' 'https://www.example.com' --all-tables-with-prefix --skip-columns=guid
wp cache flush
```

WP-CLI handles serialized data. Without the command line, the Better Search Replace plugin performs the same operation from `Tools`. Do not modify the `guid` column, which serves as an identifier for RSS feeds.

3. **Theme and plugins**: look for `http://` in the child theme files (`grep -rn "http://" wp-content/themes/montheme`), in `Appearance > Customize > Additional CSS` and in HTML widgets. Report a plugin that loads a hard-coded resource to its developer.
4. **Page builders** (Elementor, Divi): they sometimes store URLs in their own data or generated CSS files. Use their URL replacement tool and regenerate their CSS files.
5. **On-the-fly fixing plugin**: Really Simple Security (formerly Really Simple SSL) rewrites URLs at display time. Useful for troubleshooting, but it does not cover resources called from external CSS or JavaScript files: fix the database afterwards.
6. **Purge the caches** (cache plugin, CDN) and test again.

### Shopify

Versions: Online Store 2.0 themes, all plans, November 2026.

Shopify serves the store over HTTPS; mixed content comes from the theme or from content added by hand. In `Online Store > Themes > … > Edit code`, look for `http://` in the Liquid, CSS and JavaScript files. Call theme files with the `asset_url` filter and images with `image_url`, which produce HTTPS URLs. Also check the custom HTML blocks of pages and blog posts, and the scripts of uninstalled apps left in the theme.

### PrestaShop

Versions: PrestaShop 8 and 9.

Enable SSL on all pages in `Shop Parameters > General` (“Enable SSL”, then “Enable SSL on all pages”, once the certificate is in place). Then look for `http://` URLs in product and category descriptions and in content modules, and clear the cache in `Advanced Parameters > Performance`.

### Drupal

Versions: Drupal 10 and 11; Search and Replace Scanner module 2.x; Drush 12 and 13.

Replace absolute `http://` URLs in content fields (the Search and Replace Scanner module helps with large volumes), then clear the cache with `drush cr`. Check that `$settings['reverse_proxy']` is configured in `settings.php` if the site is behind a proxy, otherwise Drupal generates HTTP URLs.

### Laravel

Versions: Laravel 10 to 13.

Mixed content usually comes from URLs generated with `http://` behind a proxy. Check that `APP_URL` is on `https://` and that views use `asset()`, `url()` or `Vite::asset()` rather than hard-coded URLs. You then need to declare the trusted proxies, and this is where the versions differ.

#### Laravel 11 to 13

Declare the trusted proxies in `bootstrap/app.php`:

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

As a last resort, `URL::forceHttps(app()->isProduction());` in `AppServiceProvider::boot()`.

#### Laravel 10

Declare the trusted proxies in `app/Http/Middleware/TrustProxies.php`:

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

As a last resort, in `AppServiceProvider::boot()` (the `forceHttps()` method only exists from Laravel 11):

```php
if (app()->isProduction()) {
    URL::forceScheme('https');
}
```

### Next.js

Versions: Next.js 15 and 16, App Router and Pages Router.

Look for hard-coded URLs (`grep -rn "http://" app pages components public`, depending on the folders present) and API environment variables on `http://`. For `next/image`, declare remote sources with `protocol: 'https'` in `images.remotePatterns`. The safety net is added in `next.config.js`:

```js
module.exports = {
  async headers() {
    return [
      {
        source: '/(.*)',
        headers: [{ key: 'Content-Security-Policy', value: 'upgrade-insecure-requests' }],
      },
    ];
  },
};
```

If the site already has a full CSP, add the directive to it rather than a second header.

## Common mistakes

- **Relying on `upgrade-insecure-requests` alone**: resources unavailable over HTTPS stop loading, without anyone noticing.
- **Raw SQL search and replace on serialized data**: string lengths no longer match and settings disappear. Use the CMS tool.
- **Forgetting CSS and JavaScript files**: a background image or font called over `http://` in a stylesheet is blocked.
- **Testing only the home page**: mixed content hides in old articles, imported product pages and rarely visited templates.
- **Ignoring `srcset`**: an image that is correct in `src` but on HTTP in `srcset` is blocked on screens that choose that variant.
- **Not purging caches**: the fixed page keeps being served in its old version by the cache plugin or the CDN.
- **Keeping an on-the-fly fixing plugin indefinitely**: it hides the problem, costs processing time on every page and stops working the day it is disabled.

## Frequently asked questions

### Does mixed content prevent indexing by Google?

Not directly: the page remains crawlable and indexable. But scripts, stylesheets and iframes loaded over HTTP are blocked by the rendering browser, just as they are for the visitor. Content injected by a script loaded over HTTP therefore does not appear in the rendered page that Google indexes, and a broken layout degrades the experience. The Search Console HTTPS report does not flag this problem: check with the browser console or a crawl.

### Should http:// links to other sites be replaced?

A clickable link to another site is not mixed content: it loads nothing into your page. Replace it with its HTTPS version when one exists, to spare the visitor a redirect. Links on http:// to your own domain, however, should always be fixed: they trigger a redirect on every click and send search engines a signal pointing to the old version.

### Is the upgrade-insecure-requests header enough to fix mixed content?

No, it is a safety net. It asks the browser to load every resource over HTTPS, which removes the warnings, but a resource that does not exist over HTTPS then fails silently. The URLs remain on http:// in the database and the code, and clients that do not apply the directive keep requesting them unencrypted. Fix the URLs at the source, then keep the header as a complement.

### How do I fix mixed content on WordPress without a plugin?

Switch the WordPress Address and the Site Address to https:// in Settings > General, then replace the old URLs in the database with the WP-CLI wp search-replace command, first with the --dry-run option, excluding the guid column. Then look for remaining http:// URLs in the child theme, Additional CSS and widgets, purge the caches and check the browser console.

## Resources

- [MDN: Mixed content](https://developer.mozilla.org/en-US/docs/Web/Security/Defenses/Mixed_content)
- [web.dev: Fixing mixed content](https://web.dev/articles/fixing-mixed-content)
- [MDN: upgrade-insecure-requests directive](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/upgrade-insecure-requests)
- [Cloudflare: Automatic HTTPS Rewrites](https://developers.cloudflare.com/ssl/edge-certificates/additional-options/automatic-https-rewrites/)
- [WP-CLI: wp search-replace](https://developer.wordpress.org/cli/commands/search-replace/)
- [WordPress: improved HTTPS detection and migration in 5.7](https://make.wordpress.org/core/2021/02/22/improved-https-detection-and-migration-in-wordpress-5-7/)

Next steps: [configure security headers](https://checklist-seo-geo.com/en/security-infrastructure/configure-security-headers) and [configure HSTS if appropriate](https://checklist-seo-geo.com/en/security-infrastructure/configure-hsts-if-appropriate).
