# Fix links to redirects or non-canonical URLs

- Check 12.12 · Internal linking · Important
- Source: https://checklist-seo-geo.com/en/internal-linking/fix-links-redirects-non-canonical-urls
- Find internal links that go through a redirect or target a URL canonicalized elsewhere, and fix them at the source: CMS, theme or code.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/internal-linking/fix-links-redirects-non-canonical-urls.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

An internal link should point directly to the page's final, canonical URL: the one that returns a 200 and whose canonical tag points to itself. Yet many sites link to `http://` instead of `https://`, an address without a trailing slash that redirects, an old slug, a URL with tracking parameters or a variant canonicalized to another page. The task is to find these links, work out where they come from (template, content, CMS setting) and fix them at the source. Once done, a crawl no longer finds any internal link to a redirect or to a page canonicalized elsewhere.

## Why it matters

Google says so in its documentation on consolidating duplicates: when linking within your site, link to the canonical URL rather than a duplicate URL, because consistent links help it understand your preference. A link to a variant sends the opposite signal to your canonical; if many links repeat it, Google may pick a different URL from the one you chose.

A link to a redirect works, but it has a cost: one more request for every bot and every visitor, one more network round trip before the page displays, and sometimes a chain when the target has itself been moved. Google recommends avoiding long redirect chains, which hurt crawling, and, when URLs change, updating internal links to the old addresses.

Redirects remain useful, but for everyone else: external sites, bookmarks, old emails. Your own links are yours to fix.

## What it improves

- **Choice of canonical**: every link confirms the URL you declare. See [align canonicals, sitemap and internal links](https://checklist-seo-geo.com/en/indexing-canonicalization/align-canonicals-sitemap-internal-links).
- **Crawling**: fewer requests to redirects and duplicates. A noticeable effect on large sites.
- **Speed**: every click avoids a redirect round trip.
- **Measurement**: without `utm_` parameters on internal links, your own links no longer overwrite the traffic source of visits.
- **Rankings**: an indirect effect. The gain comes from cleaner signals, not from “link equity lost” in the redirect.

## How to check

**With Screaming Frog** (free up to 500 URLs):

1. Start the crawl from the home page's canonical URL.
2. `Response Codes` tab, `Internal` filter, then the redirects (`Redirection (3xx)`): these are the redirected URLs your pages link to. To get each link with its source page and anchor: `Bulk Export > Response Codes > Internal > Redirection (3xx) Inlinks`.
3. `Canonicals` tab, `Canonicalised` filter: pages that point to another URL. Select one, then the `Inlinks` tab at the bottom: every link listed targets a non-canonical URL.
4. `URL` tab, `Uppercase` and `Parameters` filters: they find links to uppercase variants or variants with parameters.

**On one page, from the command line**: this script lists a page's internal links that do not return a 200 directly.

```bash
SITE="https://example.com"
PAGE="$SITE/"
curl -s "$PAGE" \
  | grep -oE 'href="(/|https?://(www\.)?example\.com)[^"#]*"' \
  | sed -E 's/^href="//; s/"$//' | sort -u \
  | while read -r url; do
      case "$url" in /*) url="$SITE$url" ;; esac
      code=$(curl -s -o /dev/null -w '%{http_code} %{redirect_url}' "$url")
      case "$code" in 200*) ;; *) echo "$code <- $url" ;; esac
    done
```

Compliant result: no output. A line such as `301 https://example.com/tarifs/ <- https://example.com/tarifs` flags a link without a trailing slash.

**Across the whole site without a paid tool**: the Python script in the guide [align canonicals, sitemap and internal links](https://checklist-seo-geo.com/en/indexing-canonicalization/align-canonicals-sitemap-internal-links) flags each `LINK_TO_REDIRECT` with its source page.

## How to implement

### Before you start

Settle on the reference form of your URLs: `https`, with or without `www`, trailing slash or not, lowercase, no tracking parameters. See [standardize HTTP/HTTPS and www/non-www](https://checklist-seo-geo.com/en/indexing-canonicalization/standardize-http-https-www-non-www) and [standardize letter case and trailing slashes](https://checklist-seo-geo.com/en/architecture-navigation/standardize-letter-case-trailing-slashes). Then sort the faulty links by cause, because each cause is fixed in a different place:

| Cause | Link example | Final URL | Where to fix |
|---|---|---|---|
| Protocol | `http://example.com/tarifs/` | `https://example.com/tarifs/` | Content (bulk replace) |
| Host | `https://www.example.com/…` | `https://example.com/…` | Content, site URL setting |
| Trailing slash | `/tarifs` | `/tarifs/` | Template, menus, links typed by hand |
| Old slug | `/offres/pack-pro/` | `/tarifs/` | Content and menus |
| Tracking parameters | `/tarifs/?utm_source=blog` | `/tarifs/` | Content, internal banners |
| Canonicalized variant | `/collections/the-vert/products/sencha` | `/products/sencha` | Theme |
| Pagination page 1 | `/blog/?page=1` | `/blog/` | Pagination component |
| Index file | `/index.php`, `/accueil.html` | `/` | Logo, menu |

> **Good to know:** do not remove the redirects once the links are fixed. They remain useful for external links, bookmarks and bots that know the old addresses. See [use 301/308 for permanent moves](https://checklist-seo-geo.com/en/http-redirects/use-301-308-permanent-moves).

### Apache

Versions: Apache 2.4.

The server does not fix links, but its logs show the ones visitors and bots actually follow: a redirect whose referrer is a page on your domain is an internal link to fix. For the combined log format:

```bash
awk '($9 == 301 || $9 == 302 || $9 == 307 || $9 == 308) && $11 ~ /example\.com/ {print $11, $7}' /var/log/apache2/access.log \
  | sort | uniq -c | sort -rn | head -n 50
```

The first column counts the hits, the second gives the source page, the third the redirected URL.

### Nginx

Versions: Nginx 1.18 and later.

Same command on `/var/log/nginx/access.log`. If the logs are sent to an external service, filter the 3xx codes whose referrer belongs to your domain.

### Cloudflare

Versions: Cloudflare dashboard, all plans, November 2026.

Redirects performed at the edge (`Always Use HTTPS`, redirect rules, in the [rules overview](https://dash.cloudflare.com/?to=/:account/:zone/rules/overview)) hide the problem without solving it: the `http://` link still costs a redirect, just a faster one. Keep these rules as a safety net and fix the links on the site. Cloudflare's logs, when your plan gives access to them, allow the same filtering as in the Apache section.

### WordPress

Versions: WordPress 6.4 to 7.1, WP-CLI 2, Redirection plugin 5.

- **Links in content**: after a backup, bulk-replace the old form with the new one using WP-CLI, starting with a dry run:

```bash
wp search-replace 'http://example.com' 'https://example.com' --skip-columns=guid --dry-run
wp search-replace 'http://example.com' 'https://example.com' --skip-columns=guid
wp search-replace 'https://example.com/offres/pack-pro/' 'https://example.com/tarifs/' --skip-columns=guid
```

The Better Search Replace plugin does the same from the admin.

- **Menus**: `Appearance > Menus` (or `Appearance > Editor > Navigation`). “Custom Links” items keep the URL that was typed: replace them with Page or Category items, which follow slug changes.
- **Trailing slash**: `Settings > Permalinks` sets the form of generated URLs. Links typed by hand in content must follow the same form.
- **Site settings**: in `Settings > General`, “WordPress Address (URL)” and “Site Address (URL)” must use the reference form (`https`, correct host).
- **Detection**: the Redirection plugin logs the redirects served along with their referrer, which reveals the pages that still link to old URLs.

### Shopify

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

- **Product links in collections**: some themes build grid links with the Liquid `within` filter, which produces `/collections/the-vert/products/sencha-ariake`. Shopify points out that these URLs carry the same content as `/products/sencha-ariake`. In `Online Store > Themes > Edit code`, look for `within: collection` in the product card snippets and replace:

```liquid
<a href="{{ product.url | within: collection }}">{{ product.title }}</a>
```

with:

```liquid
<a href="{{ product.url }}">{{ product.title }}</a>
```

- **Menus and descriptions**: `Content > Menus` and the product, collection, page and blog post editors. After a URL handle change, Shopify can create the redirect, but replace the links as well.
- **Variants**: a link with `?variant=` targets a URL canonicalized to the product. Keep it where it helps the purchase (color selection), not in editorial links.

### PrestaShop

Versions: PrestaShop 8 and 9.

In `Shop Parameters > Traffic & SEO`, check that friendly URLs are enabled and that the redirect to the canonical URL option is set to 301. Then fix the links hard-coded in descriptions (`Catalog`), CMS pages (`Design > Pages`) and the menu and footer modules.

### Magento

Versions: Magento Open Source and Adobe Commerce 2.4.

In `Stores > Settings > Configuration > Catalog > Catalog > Search Engine Optimization`, two settings decide the form of product links: “Use Categories Path for Product URLs” (set to `No`, lists link to the product's short URL) and “Use Canonical Link Meta Tag For Products” (set to `Yes`). If categories appear in product URLs, list links target canonicalized variants: align the two settings, then flush the cache.

### Laravel

Versions: Laravel 10 to 13.

- **A single source of URLs**: generate links with `route()` or `url()`, never hard-coded. Set `APP_URL` to the reference form in `.env`.
- **Trailing slash**: Laravel routes are written without a trailing slash, and, under Apache, the `.htaccess` file shipped in `public/` redirects (308) URLs with a trailing slash to their form without one. So do not type `/tarifs/` in content.
- **Behind a proxy or a CDN**, configure trusted proxies so that Laravel generates `https` links. Only the location of this setting changes between versions. Failing that, force the scheme in `AppServiceProvider`:

```php
use Illuminate\Support\Facades\URL;

public function boot(): void
{
    if ($this->app->environment('production')) {
        URL::forceScheme('https');
    }
}
```

#### Laravel 11 to 13

Trusted proxies are declared in `bootstrap/app.php`:

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

Replace `'*'` with the addresses of your proxy or load balancer when you know them.

#### Laravel 10

Trusted proxies are declared in the `app/Http/Middleware/TrustProxies.php` middleware, `$proxies` property:

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

### Next.js

Versions: Next.js 15 and 16.

The `trailingSlash` option in `next.config.js` (or `next.config.ts`) sets the URL form; the `href` values of your `Link` components must follow it. After a rename declared in `redirects()`, search for the old path in the code and content:

```bash
grep -rn --include='*.tsx' --include='*.mdx' --include='*.md' '/offres/pack-pro' app content
```

### Astro

Versions: Astro 5 to 7.

The `trailingSlash` option in `astro.config.mjs` defaults to `ignore`. Set it to `always` or `never` according to your reference form, so that discrepancies become visible during development, then align the links in components and Markdown content.

### Preventing the problem from coming back

Add an automated check after each deployment: the script from the “How to check” section on the main templates, or a scheduled crawl. See [schedule automated crawls](https://checklist-seo-geo.com/en/automation-quality-control/schedule-automated-crawls).

## Common mistakes

- **Relying on the redirect**: it catches visitors, it does not replace a correct link.
- **Fixing content and forgetting the template**: a logo pointing to `/index.php` is repeated on every page.
- **Adding `utm_` parameters to internal links** to measure a banner: use a click event in your analytics tool instead.
- **Bulk replacing without a dry run**: an overly broad pattern can hit external URLs or serialized data.
- **Removing redirects after the fix**: external links and bookmarks then end up on a 404.
- **Leaving two valid URL forms returning a 200**: with no redirect or canonical, every wrong link creates an indexable duplicate.

## Frequently asked questions

### Does an internal link to a 301 redirect lose link equity?

According to Google's public statements, a permanent redirect does not make the target page lose link equity. The cost of an internal link to a redirect lies elsewhere: one more request for every bot and every visitor, a risk of a chain if the target moves again, and a less clear canonical signal. Since you control your own links, fix them so they point directly to the final URL.

### Should the redirect be removed after fixing the internal links?

No, keep the redirect in place after fixing the internal links. It serves links from other sites, visitors' bookmarks, old emails and bots that still know the old address. Fixed internal links simply stop your own site from triggering it. A redirect causes no problem as long as it leads directly to a page returning a 200.

### Are UTM parameters on internal links a problem?

Yes, UTM parameters on internal links cause two problems. They create duplicate URLs that bots crawl, even if the canonical points to the clean version. And in Google Analytics, a click on an internal link tagged with UTM parameters replaces the visit's real source with an internal campaign, which skews attribution. Measure internal clicks with events rather than URL parameters.

### How can I find internal links to redirects for free?

For a site with fewer than 500 URLs, the free version of Screaming Frog is enough: filter internal redirects in the Response Codes tab, then export their inlinks. Beyond that, a Python script or a curl loop over the links in the main templates gives the same result. Server logs, filtered on 3xx codes with a referrer from your domain, show the links that are actually followed.

## Resources

- [Google Search Central: Specify a canonical URL](https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls?hl=en)
- [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)
- [Shopify: Liquid within filter](https://shopify.dev/docs/api/liquid/filters/within)
- [WP-CLI: search-replace](https://developer.wordpress.org/cli/commands/search-replace/)
- [Laravel: URL generation](https://laravel.com/docs/urls)
- [Next.js: trailingSlash option](https://nextjs.org/docs/app/api-reference/config/next-config-js/trailingSlash)
- [Astro: configuration reference](https://docs.astro.build/en/reference/configuration-reference/)

Next steps: [fix broken links](https://checklist-seo-geo.com/en/internal-linking/fix-broken-links) and [fix redirect chains](https://checklist-seo-geo.com/en/http-redirects/fix-redirect-chains).
