# Use absolute URLs

- Check 23.04 · Hreflang and regional variants · Critical
- Source: https://checklist-seo-geo.com/en/hreflang-regional-variants/use-absolute-urls
- Write every hreflang URL in full, with https and the right domain, and fix the relative or http URLs produced behind a proxy or a CDN.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/hreflang-regional-variants/use-absolute-urls.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

Every address cited in an `hreflang` annotation must be complete: protocol, host name and path, for example `https://example.com/en/pricing/`. The forms `/en/pricing/` and `//example.com/en/pricing/` are not accepted. Once the task is done, every `hreflang` URL on the site, in tags, HTTP headers and sitemaps, is absolute, uses `https`, sits on the production domain and is identical to the canonical of the page it targets.

## Why it matters

Google's documentation on localized versions is explicit: variant URLs must be fully qualified and include the protocol (`http` or `https`). It cites the two counterexamples to avoid itself: `//example.com/foo` and `/foo`.

In an ordinary HTML document, a browser resolves a relative URL without difficulty. For `hreflang`, Google does not take that gamble: an annotation whose URL is not complete cannot be used.

The absolute URL must also be the right one. The versions in a group only recognize each other if the addresses match exactly: an annotation pointing to `http://example.com/en/pricing/` does not confirm a page whose URL is `https://example.com/en/pricing/`. Three causes produce most wrong URLs:

- the application sits behind a proxy, a CDN (Content Delivery Network) or a load balancer that talks to it over HTTP, and it generates `http://` links;
- the base URL is set to the staging domain, or to an address without `www` when the site is served with it;
- the template writes relative paths, because that is the convention for navigation links.

## What it improves

- **Usable annotations**: full URLs are the condition for Google to link the versions.
- **Reciprocity**: URLs generated the same way everywhere match each other exactly; see [check reciprocity](https://checklist-seo-geo.com/en/hreflang-regional-variants/check-reciprocity).
- **Consistency with the canonical**: the same function produces both, with no protocol or host mismatch.
- **Robustness**: pages copied by an aggregator or displayed from a cache keep annotations that point to your domain.
- **Rankings, AI answers**: no direct effect.

## How to check

Show a page's annotations and spot those that do not start with `https://`:

```bash
curl -s https://example.com/fr/tarifs/ | grep -o -i '<link[^>]*hreflang[^>]*>' | grep -v 'href="https://'
```

Correct result: no lines. To check the host as well, replace the last filter with `grep -v 'href="https://example.com/'`. If your versions are on country domains (`example.de`), it is normal for them to show up: check that they are indeed the production domains.

In a sitemap:

```bash
curl -s https://example.com/sitemap.xml | grep -o 'xhtml:link[^>]*' | grep -v 'href="https://'
```

For a PDF:

```bash
curl -sI https://example.com/fr/guide.pdf | grep -i '^link:'
```

Each URL between `<` and `>` must be complete.

Other ways:

- **Screaming Frog**: with "Store Hreflang" and "Crawl Hreflang" ticked, export the Hreflang tab and filter the addresses that do not start with `https://`. The "Not Using Canonical" and "Non Canonical Return Links" filters also flag annotations that do not use the canonical URL.
- **Merkle's hreflang tester**: shows the URLs as they are written in the page.

## How to implement

### Before you start

One URL form for the whole site: `https`, the chosen host (with or without `www`), a trailing slash policy, no tracking parameters. It is set in [standardize HTTP/HTTPS and www/non-www](https://checklist-seo-geo.com/en/indexing-canonicalization/standardize-http-https-www-non-www) and checked in [check canonicals and absolute URLs](https://checklist-seo-geo.com/en/indexing-canonicalization/check-canonicals-absolute-urls).

Expected form:

```html
<link rel="alternate" hreflang="fr" href="https://example.com/fr/tarifs/">
<link rel="alternate" hreflang="en" href="https://example.com/en/pricing/">
```

To avoid:

```html
<link rel="alternate" hreflang="en" href="/en/pricing/">
<link rel="alternate" hreflang="en" href="//example.com/en/pricing/">
<link rel="alternate" hreflang="en" href="http://example.com/en/pricing/">
<link rel="alternate" hreflang="en" href="https://staging.example.com/en/pricing/">
```

A `<base href>` tag does not solve anything: write the full URL in every annotation. Generate the canonical and `hreflang` with the same function, so that they cannot diverge.

### Apache

Versions: Apache 2.4.

If Apache is the reverse proxy in front of the application, pass on the original protocol and host so that the application generates `https` URLs:

```apache
RequestHeader set X-Forwarded-Proto "https"
ProxyPreserveHost On
```

For a `Link` header on a PDF, hard-code the full URL:

```apache
<Files "guide.pdf">
    Header set Link "<https://example.com/fr/guide.pdf>; rel=\"alternate\"; hreflang=\"fr\", <https://example.com/en/guide.pdf>; rel=\"alternate\"; hreflang=\"en\""
</Files>
```

Reload with `sudo apachectl configtest && sudo systemctl reload apache2`.

### Nginx

Versions: Nginx 1.18 and later.

In front of an application (Node.js, PHP-FPM), pass on the host and protocol:

```nginx
location / {
    proxy_pass http://127.0.0.1:3000;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Host $host;
}
```

For PHP-FPM, check that `fastcgi_param HTTPS $https if_not_empty;` is present (included in `fastcgi_params` on most distributions). Reload with `sudo nginx -t && sudo systemctl reload nginx`.

### Cloudflare

Versions: Cloudflare dashboard, all plans, November 2026.

In the "Flexible" SSL/TLS mode, Cloudflare reaches your server over HTTP: the application believes it is served over `http://` and may write that in its annotations. Install a certificate on the origin, then, in [`SSL/TLS > Overview`](https://dash.cloudflare.com/?to=/:account/:zone/ssl-tls), choose the custom "Full (strict)" option, or let the automatic mode (Automatic SSL/TLS) pick the most secure mode the origin supports. Then purge the cache to replace the pages already stored.

### AWS

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

Behind an **Application Load Balancer**, the application receives HTTP with the `X-Forwarded-Proto` header: configure it to trust the proxy (see Laravel, Symfony, WordPress, Drupal). Behind **CloudFront**, forward the `Host` or `CloudFront-Forwarded-Proto` header to the origin in the origin request policy, or hard-code the base URL in the application. On a static **S3** site, the base URL is the generator's, to be set at build time.

### WordPress

Versions: WordPress 6.4 to 7.1; WPML 4.5 and later for per-language domains.

Multilingual plugins build URLs from the site settings:

- `Settings > General`: "WordPress Address (URL)" and "Site Address (URL)" in `https://` on the final domain.
- Behind a proxy or a CDN that terminates TLS, add this to `wp-config.php`, before the line `require_once ABSPATH . 'wp-settings.php';`:

```php
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
    $_SERVER['HTTPS'] = 'on';
}
```

- With WPML and a different domain per language, each domain entered in `WPML > Languages` must be the full production address.

After a migration from staging, replace the old domain in the database with a search-and-replace tool that handles serialized data, then clear the caches.

### Shopify

Versions: Shopify admin, all plans, November 2026.

Shopify Markets' automatic tags are absolute and follow the domains configured for each market. Check that each market's primary domain is the one you want indexed.

### Drupal

Versions: Drupal 10 and 11.

Content Translation generates absolute URLs from the request. Behind a proxy, declare it in `settings.php` so that Drupal keeps the original protocol and host:

```php
$settings['reverse_proxy'] = TRUE;
$settings['reverse_proxy_addresses'] = ['10.0.0.10'];
```

Replace the address with your proxy's, then run `drush cr`.

### Laravel

Versions: Laravel 10 to 13. Only where proxy trust is configured changes from Laravel 11 onwards.

`route()` and `url()` return absolute URLs, built on the request's host and protocol. Do not use `route('...', absolute: false)` for annotations. Two settings prevent wrong URLs:

- `APP_URL=https://example.com` in `.env`, used outside HTTP requests (queues, sitemap generation from the command line);
- trusting the proxy, so that the application keeps the original protocol and host.

#### Laravel 11 to 13

In `bootstrap/app.php`:

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

Restrict `at` to your proxies' addresses when you know them.

#### Laravel 10

The `app/Http/Middleware/TrustProxies.php` middleware is already registered in `app/Http/Kernel.php`. Set its `$proxies` property:

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

Replace `'*'` with an array of your proxies' addresses when you know them.

### Symfony

Versions: Symfony 6.4, 7.4 and 8.x.

Use `url()` in Twig, never `path()`, which produces a relative path. Behind a proxy, declare it in `config/packages/framework.yaml`:

```yaml
framework:
    trusted_proxies: '127.0.0.1,REMOTE_ADDR'
    trusted_headers: ['x-forwarded-for', 'x-forwarded-host', 'x-forwarded-proto', 'x-forwarded-port']
```

For URLs generated from the command line (sitemaps), set `default_uri: 'https://example.com'` under `framework.router`.

### Next.js

Versions: Next.js 15 and 16 (App Router).

Declare `metadataBase` in `app/layout.tsx`; Next.js then completes the relative paths in `alternates.languages`:

```ts
export const metadata = {
  metadataBase: new URL('https://example.com'),
};
```

Next.js refuses to build a relative URL field without `metadataBase`. Take the value from an environment variable if staging has its own domain, checking that it is indeed the production domain in the production build.

### Nuxt

Versions: Nuxt 3 and 4, with the @nuxtjs/i18n module 9 and 10.

With `@nuxtjs/i18n`, the `baseUrl` option is required for alternate links to be complete:

```ts
export default defineNuxtConfig({
  i18n: {
    baseUrl: 'https://example.com',
  },
});
```

### Astro

Versions: Astro 5 and 6.

Set `site: 'https://example.com'` in `astro.config.mjs`, then build each URL with `new URL(path, Astro.site).href`. Without `site`, `Astro.site` is undefined and URLs cannot be completed.

## Common mistakes

- **Copying the logic of navigation links**, relative out of habit, into the annotation template.
- **`http://` URLs behind Cloudflare or a load balancer**: the application does not know the original request was over HTTPS.
- **Staging domain in production**: `APP_URL`, `metadataBase` or `siteurl` left on `staging.example.com`.
- **A host different from the canonical**: annotations without `www`, canonical with it, or the reverse.
- **Protocol-relative URLs** (`//example.com/…`), sometimes produced by old themes.
- **Fixing the tags but not the sitemap** or the HTTP headers, when several methods coexist.

## Frequently asked questions

### Can you use relative URLs in hreflang tags?

No. Google's documentation requires fully qualified URLs, with the protocol: https://example.com/foo is accepted, but not /foo or //example.com/foo. A relative URL works for a navigation link, not for an hreflang annotation. Generate the URLs with a function that produces the absolute address, the same one used for the canonical tag, and check the result in the source code served.

### Can hreflang URLs point to another domain?

Yes. Google states that a page's variants do not need to be on the same domain: example.fr can announce its German version on example.de. Each URL simply has to be complete and use https, and the target page must respond with its own annotations pointing back to the first. Country domains, subdomains and subdirectories can therefore be mixed in the same group.

### Why are my hreflang annotations in http when the site is in https?

It is almost always a proxy: Cloudflare in Flexible mode, a load balancer or an Nginx server reaches the application over HTTP, and the application then generates http addresses. Switch Cloudflare to Full (strict), pass on the X-Forwarded-Proto header and configure the application to trust the proxy, or set the base URL to https in its configuration. Then purge the caches.

### Does the trailing slash matter in an hreflang URL?

Yes. For Google, https://example.com/en/pricing and https://example.com/en/pricing/ are two separate URLs, even if one redirects to the other. The URL cited in the annotation must be exactly the canonical URL of the target page, with or without a trailing slash according to the site's rule. Otherwise, the target is a redirect and the return link no longer matches.

## Resources

- [Google Search Central: Tell Google about localized versions of your page](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=en)
- [Next.js: metadataBase](https://nextjs.org/docs/app/api-reference/functions/generate-metadata#metadatabase)
- [Nuxt i18n: SEO and hreflang](https://i18n.nuxtjs.org/docs/guide/seo)
- [Laravel: Configuring trusted proxies](https://laravel.com/docs/requests#configuring-trusted-proxies)
- [Symfony: How to configure Symfony to work behind a load balancer or a reverse proxy](https://symfony.com/doc/current/deployment/proxies.html)
- [Cloudflare: SSL/TLS encryption modes](https://developers.cloudflare.com/ssl/origin-configuration/ssl-modes/)

Next steps: [Validate ISO 639-1 language codes](https://checklist-seo-geo.com/en/hreflang-regional-variants/validate-iso-639-1-language-codes), [Check that targets return HTTP 200](https://checklist-seo-geo.com/en/hreflang-regional-variants/check-that-targets-return-http-200) and [Align hreflang and canonical](https://checklist-seo-geo.com/en/hreflang-regional-variants/align-hreflang-canonical).
