# How to add redirects on Search?

In the case you've built specific landing pages to display search results, it becomes really handy to be able to redirect users to those dedicated pages in the case their search query matches one of those.

&#x20;\### Example Let's say you have an e-commerce website where you sell "star wars" related goods, and you'd like to redirect the user searching for "star wars" (or any related words) to a shiny Star Wars page.

No problem, that can be easily done in a few steps:

1Create a new index that will contain all the redirection rules. \_We can, for instance, name it 'redirects'.\_

2Add to that index records containing the URL of the landing page and an array of keywords that will trigger the redirection.

```
{
  "url": "https:// ....",
  "query_terms": ["star wars", "jedi", "darth vader", "george lucas", "luke skywalker"]
}
```

3Configure the index settings:

* Add the 'query\_terms' attribute to the attributesToIndex list.  &#x20;

  *If \_the query terms order doesn't matter, \_set the attribute to 'unordered'.*

![](https://s3.amazonaws.com/helpscout.net/docs/assets/557c2386e4b01a224b42b2b3/images/56961ae19033603f7da30506/file-phekJbVAy4.png)

* Set the Typo Tolerance to min

![](https://s3.amazonaws.com/helpscout.net/docs/assets/557c2386e4b01a224b42b2b3/images/56961f339033603f7da3052d/file-UqHM0ctdIt.png)

* Enable the ignorePlural option

![](https://s3.amazonaws.com/helpscout.net/docs/assets/557c2386e4b01a224b42b2b3/images/5696247cc69791436155e2ec/file-cf3q0nIqA0.png)

* Enable the removeWordsIfNotResults option and set it to 'allOptional'

![](https://s3.amazonaws.com/helpscout.net/docs/assets/557c2386e4b01a224b42b2b3/images/56962490c69791436155e2ed/file-6EeyZYqpr1.png)

4Implement a small business logic on the client side:

* At each new keystroke in the search field, perform a search against that index to retrieve a single result (hitsPerPage=1). &#x20;

*If you're using Javascript, you can find more details about the way to call multiple indices at the same time at* [*https://github.com/algolia/algoliasearch-client-js#multiple-queries*](https://github.com/algolia/algoliasearch-client-js#multiple-queries)

* When the user presses enter (or clicks on the search icon) and if there is a result returned by that search query, use the "url" value to redirect the user to the correct page.&#x20;

Happy coding! If you have any question, feel free to reach out to our support!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://samypesse.gitbook.io/algolia-faq/searching/how-to-add-redirects-on-search.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
