Home > other >  Redirect deep links with changing values to homepage in wix
Redirect deep links with changing values to homepage in wix

Time:02-17

I want to redirect a deep link like this: https://www.mywixsite.com/lessons/{id} to my wix site homepage (not in the error page where it redirects now).

The id value in the url is different every time, as the deep link changes. How can I achieve redirection to the homepage from the above url for every different id?

Wix gives you the option through the dashboard to redirect specific urls like https://www.mywixsite.com/lessons to another page, but what happens when the url includes a value that is changing every time?

CodePudding user response:

You can use wix-router to catch lessons/{id} requests and redirect to the home page.

  1. Create the lessons router (here is how)
  2. Add the following code to the routers.js file (which created for you in the last step)
export function lessons_Router(request) {
   const id = request.path[0];
   return redirect(`https://www.mywixsite.com?id=${id}`);
}

It will redirect the user from https://www.mywixsite.com/lessons/1 to https://www.mywixsite.com/?id=1 so you can identify from what lesson id the user came from.
If you don't need the id, you can remove it of course.

Example website

  • Related