URL Redirects & Velo Javascript

Ok, look…

…you normaly should get logs like…


…but with more expanded data…

Take a closer look onto PAGE-URL, does it reflect the right URL?

  1. OLD-PRODUCT-URL ???
  2. NEW-PRODUCT-URL ???

And where did you setup the URL-REDIRECT?

Maybe you want to code the redirect by your own ?

You see now the URL, right?

What woulb be now the right logic?

You click onto your chosen PRODUCT.
Product-data gets loaded including the URL (old/new) however.

It is navigating you to the → OLD ← PRODUCT-PAGE…

That means the redirect do not work (whereever you have setted it up, it do not work).
So you have to refresh the page, but wait, after page-refresh it works!

So what if you could start an automatic → PAGE-REFRESH → by CODE? ?

1 Like

My question woulbe if there is a systematical URL-CHANGE between old and new URL ?

If there is a possibility to generate a systematical URL-CHANGE, you maybe even do not need a page-refresh.

Only you know the difference between OLD and NEW URL.

If you again would take a deeper look onto my provided example-site, you would find someting like…

$w(‘#productPage1’).onMouseIn(()=>{start_Process();});

…or if you take a look here…

…you will find something like…
$w(‘#checkbox1, #checkbox2’).onChange(()=> {check_Checkboxes();});

You already recognize what i want to tell you ?

What about —>

$w('#CLICKED-ELEMENT-ID-HERE').onClick(()=> { .........what should happen now...........});

Your CONSOLE-LOGS do start with → PAGE-LOAD.
Now you need to generate an → INTERACTION <— so you click on something → to start a process.

So you surely want to click onto the PRODUCT or a BUTTON → What is the ELEMENT-ID of it? Paste the ID into the code and start a function…–> function → xxxxx();

$w('#CLICKED-ELEMENT-ID-HERE').onClick(()=> {xxxxx();});

Now generate the function —> What should happen when you click that element?

function xxxxx() {console.log('XXXXX-FUNCTION started....');
    console.log('What should happen next?');
    console.log('Start of REDIRECT...');
    wixLocationFrontend.to(URL);
}

But before you can use it →

a) you need to import the corresponding VELO-MODULE…
—> import wixLocationFrontend from 'wix-location-frontend’; ← will go to the very top of code!!!

b) you will have first to define/declare the URL - variable or constant.

const URL = ‘https://xxxxxx/product/cutting.../whatever…’

Now try to put all together…

I checked out your video. I’m still trying to decipher what issue you are having. So I will give it another go …

What I think you are saying is … you have an old Wix website (that is still has a domain connected, which means it has a premium that is not expired) that is auto-redirecting to an incorrect URL.

And your incorrect URL is auto-redirecting itself to the new and correct URL?

Is that about right?

You can’t fix that via Velo unless the old Wix site actually has Velo on the product page and/or Wix Dashboard Custom Code settings and/or the backend coding section of the editor.

If the original re-direct was not done via Velo, then it was done via the 301 redirect dashboards settings via the Wix Dashboard area. Setting Up a 301 Redirect for a Page on Your Site | Help Center | Wix.com

By the way … once you have figured all of that out — -make sure you cancel your old Wix website premium plan > disconnect the domain from the site and re-connect it to your new Wix site. Then … all of the old pages with the same URL pattern will auto-redirect, and any new patterns can be added to the URL Redirect Manager via the Wix Dashboard settings. Unless you don’t want to do that ----- you will have to keep your Old Wix premium plan active in order to keep the redirects going. It is a premium feature that is not available for free Wix sites.

2 Likes