VTEX Developer Portal

Managing URL Redirects

Managing URL Redirects


The URL redirect is very advantageous when you want a given web page's accesses to be redirected to another of your choosing.

You may want to do this for any number of reasons, such as a change to the URL path or for users from a specific region to have access to a custom web page.

No matter the reason: it's likely that your website has already, is currently or will require a redirect from one URL to another.

Therefore, VTEX IO offers a fast and easy way to add, remove and manage your store's URL path redirects using Toolbelt, our CLI. Check it out:

Step by step

Adding redirects

  1. Open a .csv file of your choosing. You can use Excel or Google sheets, for example;
The file must be a .csv type file. Otherwise, the redirects upload will not work.
  1. Once opened, create four columns in those files with the following values: from, to, type and endDate. For example:

csv-file-url-redirectcsv-file-url-redirect

Property nameDescriptionExample
fromOriginal path, the path you want to create a redirect from/blouse/p
toNew path or URL the one users will be redirected to/blouse/p?skuId=2000549
typeThe type of the redirect (TEMPORARY or PERMANENT)TEMPORARY
endDateDate, on the format mm/dd/yyyy at which the redirect will expire. Notice that if the redirect is permanent, no value for endDate is required.5/20/2020
Only the to column accepts domains, such as myotherstore.com or mystore.myvtex.com. You should not use them in the from column.
TEMPORARY type redirects will receive the 302 status code, while PERMANENT type ones will receive the 301 status code.
  1. Fill in the cells under each column with the values desired for your store. Remember that each redirect's data must be entered on different lines, as shown in the example below:

urls-redirect-csv-fileurls-redirect-csv-file

  1. Save and name the document as desired;
  2. Using your terminal and the VTEX IO Toolbelt, log into your VTEX account;
  3. Once logged in, run the vtex redirects import {fileName}.csv, replacing {fileName} with the name of the file that you've just saved.

After the sixth step, Toolbelt will receive the file, validate it, and save it. After that, the redirects will take effect.

Removing redirects

  1. Using your terminal and VTEX IO Toolbelt, log into your VTEX account;
  2. Once logged in, run the vtex redirects delete {path}, replacing{path} with the URL path that will have its redirect removed.
The path that is sent when running vtex redirects delete {path} will have its redirect removed, so it must be one of paths from the `from` column of the .csv type file.

Verifying redirects

To check the site redirects that are saved on the platform's data bank, simply log into your VTEX account and run vtex redirects export {fileName}.csv , replacing {fileName} with the name of the csv file holding the site redirects.

This will tell Toolbelt to return the full list of saved redirects to your local files.

Updated 10 days ago


Managing URL Redirects


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.