Delayed Redirect Via Router?

Hello,

Due to current page nesting limits, I would like to create a number of pseudo-pages for menu purposes that then 301 redirect users to the hidden deeper pages that are only available via deeper links unfortunately due to our number of layers and categories and items and Wix nesting limits at this time (2 levels max).

Now, I used to run my own little code previously in html widget and add a little delay and a little gif loader image for fancy pants effects, and then opened my desired page for them.

What is the best way to do this here with Wix code now?

Requirements: 3 second delay (SHOW PAGE for 3 seconds, then redirect)

I found this bit but am not quite sure what I need to do, going to read up on router and find out what I can, but these guides on the API side just seem too dry, maybe more WHOLE examples could be more helpful for noobs like me to understand what happens better. I still cannot find out if delaying is a thing for this. If not possible, I can easily fall back to my old school way, but here I am trying to learn best practices under the limits and circumstances.

 import {redirect} from 'wix-router'; export function myRouter_Router(request) { return redirect("http://myothersite.com", "301"); } 

Hey
Use the javascript function setInterval and use wix-location to redirect the user if you don’t need the 301 or use the redirect you found.

Good idea,

It is probably preferred to use setTimeout (if you only need it to happen once).

Liran.

The redirect needs to happen all the time. It needs to be 301, preferably. I will try mixing in setTimeout and the other comment with the stuff on that API page and see what I end up with.

Thanks gents

So I still was not able to quite figure it out with the router stuff.

I went ahead and embedded an html widget with the following code instead since I am in rush. But for my own learning purposes, exactly how many more steps I would have to take to make this possible?

I have no SEO issues with this either as I know Google does pick it up and respects it, but I would love to be able to send a 301 code in the process as well if possible so that there is no room for doubt. Essentially, I cannot and do not want to use the 301 redirect because I want to show a little animation on the page as the “redirect” takes place (this being THE goal here) and just wanted to find the most appropriate way to go about it under Wix Code.

Trigger on 2 second mark from source page

<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
setTimeout(function () {
    parent.location.replace("https://www.alexthedefender.com/contact-alexander-houthuijzen-pllc");}, 2000);
</script>
</body>
</html>

I suppose after all I should use this bit, can you guys confirm?

My understanding so far is I should first create this:

export function ROUTERNAME(request) { let redirectUrl = response.redirectUrl; // " https://www.alexthedefender.com/contact-alexander-houthuijzen-pllc " }

The, I should call this ROUTERNAME via this ON MY SOURCE PAGE? Correct? Am I missing something?

 setTimeout(function () { 
  export function ROUTERNAME(request) {response.status = 301;}, 2000);  
  };

Meanwhile… congrats again and again guys… WHAT A FAR CRY FROM THIS NONSENSE. Remember that crap and how they rubbed in our faces, but now this is going places lol

I try this and cannot get it to setup even, says response is undefined when I attempt to define LET

Hey
I believe a router is only executed by running a page. I don’t know if you can call on a routers code from another page. If you want some code to be executed from a page it is way better to just add a backend module which is to call from any page.

So if you just want to redirect from one or more pages just add the below.

import wixLocation from ‘wix-location’;

$w.onReady(function () {

var myVar = setInterval(function(){ 
	wixLocation.to("http://wix.com"); 
	}, 3000); 

});