1

I am having an issue with Google Search Console saying that there are too many redirects on my homepage. So basically, I want the redirect to happen to both - http and non-www, it means i want both to be https://www.fiziokaspars.lv. So i want both https AND www. But right now, when i enter curl -I -L http://fiziokaspars.lv, i get double redirect:

C:\Users\user>curl -I -L http://fiziokaspars.lv
HTTP/1.0 308 Permanent Redirect
Content-Type: text/plain
Location: https://fiziokaspars.lv/
Refresh: 0;url=https://fiziokaspars.lv/
server: Vercel

HTTP/1.0 301 Moved Permanently
Cache-Control: public, max-age=0, must-revalidate
Content-Type: text/plain
Date: Thu, 30 Jan 2025 11:55:06 GMT
Location: https://www.fiziokaspars.lv/
Server: Vercel
Strict-Transport-Security: max-age=63072000
X-Vercel-Id: arn1::gftqt-1738238106226-4955f86f010f

HTTP/1.0 200 OK
Accept-Ranges: bytes
Access-Control-Allow-Origin: *
Age: 207
Cache-Control: public, max-age=0, must-revalidate
Content-Disposition: inline
Content-Length: 73664
Content-Type: text/html; charset=utf-8
Date: Thu, 30 Jan 2025 11:55:06 GMT
Etag: "b9b44a87d39dce2c6f55095eb3a12c91"
Server: Vercel
Strict-Transport-Security: max-age=63072000
Vary: RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Router-Segment-Prefetch
X-Matched-Path: /
X-Nextjs-Prerender: 1
X-Nextjs-Stale-Time: 4294967294
X-Vercel-Cache: HIT
X-Vercel-Id: arn1::vqq6x-1738238106385-30dc64cd9508

First, from http://fiziokaspars.lv to https://fiziokaspars.lv, and then to https://www.fiziokaspars.lv. How can i prevent the first redirect and do it with 1 redirect only? Cause this messes up with my google search console.

My next.config.ts file:

import { NextConfig } from 'next'

const config: NextConfig = {
  async redirects() {
    return [
      // Redirect from non-www HTTP to HTTPS www
      {
        source: '/:path*', // Capture all paths
        has: [
          {
            type: 'host',
            value: 'fiziokaspars.lv',
          },
        ],
        destination: 'https://www.fiziokaspars.lv/:path*', // Redirect to the www version
        permanent: true,
      },
      // Redirect from non-www HTTPS to www
      {
        source: '/:path*',
        has: [
          {
            type: 'host',
            value: 'fiziokaspars.lv',
          },
        ],
        destination: 'https://www.fiziokaspars.lv/:path*', // Redirect to the www version
        permanent: true,
      }
    ]
  }
}

export default config

This is my domains page in vercel: Vercel domains page

2
  • You shouldn't need to add redirects for https, vercel does this automatically. For www redirects, you can set the domain in vercel (which you've done according to the screenshot). Commented Jan 30 at 12:29
  • @Reyno cleared my next.config.ts, there are no more additional redirects, only the one from the vercel/domains screenshot. But still it gives me double redirect that messes up with google seo. Maybe I need to change the Status Code for the redirect in Vercel for fiziokaspars.lv? Commented Jan 30 at 13:01

1 Answer 1

0
  1. Go to Vercel Dashboard -> Select your project.
  2. Navigate to Settings -> Domains.
  3. Find fiziokaspars.lv, click the three dots, and select Redirect to www.fiziokaspars.lv.
  4. Remove redundant redirects from next.config.ts to avoid conflicts.
Sign up to request clarification or add additional context in comments.

2 Comments

Edited my post, added the image from vercel/domains, so I have already added the redirect to www.fiziokaspars.lv. Tried to find an answer with chatGPT, but nothing worked and it started to loop the answers...
Same problem bro

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.