Skip to main content
Search isn’t only about retrieving results. Sometimes, depending on what users search for, you might want to redirect them to a specific page of your website or mobile app. Redirecting searches to a URL helps users in these cases:
  • Improve user experience and navigation. For example, searching for “help” or “return policy” redirects users to a support page.
  • Display category pages for related keywords to guarantee a consistent user experience and boost SEO by driving more traffic to category pages. For example, searching for a category keyword, such as, “TV” redirects users directly to the corresponding category page.
  • Promotional campaigns. For example, searching for a specific artist name or brand redirects users to a landing page created specifically to support a promotional operation.
  • Crisis management. Provide relevant answers to queries related to sudden events. For example, if you detect that your users suddenly start searching for “masks”, redirect them to a specific landing page.
Algolia lets you create redirects to specific URLs with the Autocomplete redirect plugin or a custom implementation

Algolia out-of-the-box redirect solution

The easiest way to redirect search queries to a URL is by adding a rule with the Visual Editor. The rule adds data to the search response, which you can handle in your frontend. The examples on this page add a redirect for the keyword “help” to a support page. You can discover potential redirects by looking at your search analytics. For example, users searching for “help” and not getting any results.

Using the Visual Editor

  1. In the Algolia dashboard, select your application and index, open Rules, and select New rule > Visual Editor.
  2. Click Set query condition(s), select Contains, enter help, and click Apply.
  3. In Consequences, expand More consequences and select Redirect. Enter the URL for your support page and click Apply.
  4. Click Review and Publish, review the rule, and click Publish.

Using the API

To run the code examples on this page, install the latest API client. To add a rule with the API, use the saveRule method. When adding a rule, you need to define a condition and a consequence. In the consequence, add a search parameters and configure renderingContent using the following template:
JSON

Handle redirects in your user interface

After adding the rule, you can trigger the redirect in your UI when the renderingContent.redirect property is present in the API response. You have two options:

Extend the out-of-the-box approach or create custom redirection

If you want to define your own redirection format, or if you need to add additional attributes to the default redirect rule format, you can create a rule with either editor that returns custom data.

Create a rule for returning custom data

You can set a rule that contains the custom data you need to build your custom redirect. This example redirects users to your support page whenever the contains “help”.

Using the dashboard

You can add this rule from the Algolia dashboard using either the Visual Editor or the Manual Editor.
  1. Open Rules and select New rule > Visual Editor.
  2. Click Set query condition(s), select Contains, enter help, and click Apply.
  3. In Consequences, expand More consequences and select Return custom data. Enter { "redirect": "https://www.algolia.com/support" } in Value and click Apply.
  4. Click Review and Publish, review the rule, and click Publish.

Using the API

To add a rule with the API, use the saveRule method. When setting a rule, you need to define a condition and a consequence.

Handle redirects in your user interface

After adding the rule, you can trigger the redirect in your UI when the userData property is present in the API response. If you’re using one of the InstantSearch UI libraries, see Redirects in InstantSearch.

Add redirects using a dedicated index

You can set up redirects by creating a separate index with the list of redirects and the queries that trigger them. Whenever a user performs a search, you have to look in two indices: the regular index to search for items, and the redirect index that determines whether users should be redirected. This technique is useful if you can’t use rules, or if you want to use other Algolia Search features with your redirect queries, such as typo tolerance, synonyms, or a .

Dataset

JSON
Each record in this dataset has a url to redirect the queries, and a list of query_terms, that trigger the redirect. For example, the query “star wars” should redirect to https://www.google.com/#q=star+wars.

Configure the redirect index

To trigger the redirect only if the query exactly matches one of the query terms, add query_terms to the list of attributesForFaceting, so that you can filter on it:

Create a custom search client

You need to create a custom search client that simultaneously sends requests to the regular and redirect indices. The request to the redirect index is sent with:
  • An empty query, so it doesn’t filter with it
  • A filter on query_terms with the content of the current query, to match only that contain the current query exactly
  • hitsPerPage=1, as you only need the first record
Whenever a record matches in the redirect index, a redirect is triggered:
Last modified on September 28, 2026