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
- Open a
.csv
file of your choosing. You can use Excel or Google sheets, for example;
.csv
type file. Otherwise, the redirects upload will not work.
- Once opened, create four columns in those files with the following values:
from
,to
,type
andendDate
. For example:
Property name | Description | Example |
---|---|---|
from | Original path, the path you want to create a redirect from | /blouse/p |
to | New path or URL the one users will be redirected to | /blouse/p?skuId=2000549 |
type | The type of the redirect (TEMPORARY or PERMANENT ) | TEMPORARY |
endDate | Date, 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 |
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.
- 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:
- Save and name the document as desired;
- Using your terminal and the VTEX IO Toolbelt, log into your VTEX account;
- 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
- Using your terminal and VTEX IO Toolbelt, log into your VTEX account;
- Once logged in, run the
vtex redirects delete {path}
, replacing{path}
with the URL path that will have its redirect removed.
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