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 . So i want both https AND www. But right now, when i enter curl -I -L
, i get double redirect:
C:\Users\user>curl -I -L
HTTP/1.0 308 Permanent Redirect
Content-Type: text/plain
Location: /
Refresh: 0;url=/
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: /
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 to
, and then to
. 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: '/:path*', // Redirect to the www version
permanent: true,
},
// Redirect from non-www HTTPS to www
{
source: '/:path*',
has: [
{
type: 'host',
value: 'fiziokaspars.lv',
},
],
destination: '/:path*', // Redirect to the www version
permanent: true,
}
]
}
}
export default config
This is my domains page in vercel:
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:
fiziokaspars.lv
, click the three dots, and select Redirect to
www.fiziokaspars.lv
.