---
title: How do I perform Vercel redirects based on query strings?
description: When using redirects with the `vercel.json` or `next.config.js` configuration file, your URL may contain query parameters that you would like to use in your re-direction, this is possible with 2 different methods.
url: "https://vercel.com/kb/guide/how-do-i-perform-vercel-redirects-based-on-query-strings"
published: 2025-11-03
last_updated: 2026-10-02
authors: Ismael Rumzan
install_vercel_plugin: npx plugins add vercel/vercel-plugin
---

When using redirects with the [`vercel.json`](https://vercel.com/docs/configuration#project/redirects) or [`next.config.js`](https://nextjs.org/docs/api-reference/next.config.js/redirects) configuration file, your **URL** may contain query string parameters that you would like to use in your redirection. This article explains the two methods possible to achieve this.

## Include query strings in redirect destination

By default, all query strings that are found in the **source** path will be passed to the **destination** path. In the example configuration below, if the source is `/?baz=10`, the destination will be `/lol/?path=foo&baz=10`.

```json
{
   "redirects":[
      {
         "source":"/",
         "destination":"/lol/?path=foo"
      }
   ]
}
```

## Redirect based on value of query string

Using the `has` property, you can redirect to a specific route based on the value of the query parameter being present. For example, in the configuration below, if the source is `/specific/mypath?page=home&id=1000`, it will be redirected to `/another/mypath?page=home&id=1000`.

```json
{
  "redirects": [
    {
      "source": "/specific/:path*",
      "has": [
        {
          "type": "query",
          "key": "page",
          "value": "home"
        }
      ],
      "permanent": false,
      "destination": "/another/:path*"
    }
  ]
}
```

For details related to using the `has` field, review this [page](https://nextjs.org/docs/api-reference/next.config.js/redirects#header-cookie-and-query-matching) for `next.config.js` and this [page](https://vercel.com/docs/project-configuration#project-configuration/redirects) for `vercel.json`.

## Related Documentation

- [Next.js](/docs/frameworks/full-stack/nextjs)

## More Next.js guides

- [Migrate self-hosted Next.js and containers from AWS to Vercel](/kb/guide/migrate-containers-from-aws-to-vercel): Migrate Next.js apps and HTTP containers from AWS to Vercel. Configure AWS access, assess background workers, and plan testing, DNS cutover, and rollback.
- [Migrate a Next.js app from Webflow Cloud to Vercel](/kb/guide/migrate-a-next-js-app-from-webflow-cloud-to-vercel): Move your Next.js app from Webflow Cloud to Vercel: remove the OpenNext Cloudflare adapter, drop the base path, map storage bindings to Vercel Blob, Redis, and Postgres, and deploy with Git or the vercel CLI.
- [How to revalidate Sitecore pages on publish with Next.js](/kb/guide/update-sitecore-content-manually): Learn how to use a Sitecore Experience Edge webhook and Next.js revalidatePath to refresh cached Sitecore Content SDK pages after each publish.