Good afternoon,
I ported my client's old site to Wix and kept the same domain. I'd like some guidance on creating a 301 that the built in group redirects and router solutions listed in Wix's documentation don't seem to handle.
The old site was php, and the urls were like:
https://www.mydomain.com/oldpage.php?somequeryparam=0001
This should redirect to the Wix site at the dynamic url:
https://www.mydomain.com/newpage/0001
The old site could also contain, or not contain the leading 0's in the 4 character query parameter value. So these two urls are both valid and equivalent, and exist all over the web in people's bookmarks, wikipedia, etc.
https://www.mydomain.com/oldpage.php?somequeryparam=1
https://www.mydomain.com/oldpage.php?somequeryparam=01
https://www.mydomain.com/oldpage.php?somequeryparam=001
https://www.mydomain.com/oldpage.php?somequeryparam=0001
On Wix's site, the dynamic page title is always 4 digits, and leading 0's are required.
I can easily parse the old URLs coming in and create a well formed Wix dynamic URL. That's not the problem.
The problem is that I don't see anywhere to create a 301 that requires custom code like this.
I can create a group redirect, but I have no way of turning:
?somequeryparam=1
into the Wix dynamic URL:
/0001
That requires custom code, and I don't see a way to add a hook or custom code to the group redirect.
Possibly, I could create a new page just for the sole purpose of sending the group redirect to a valid page that is NOT a 404. And on that page, I could parse out the query param and do a wixLocation.to(). But that's not optimal either, as it records the redirected page as the kludgy intermediary page, not the actual final page. wixLocation.to does not send a formal redirect. The only API I've found that sends a formal redirect is router.redirect. But you can't use that code outside of the actual router.js (I couldn't import router into page code).
Then there are some suggestions to using the router to do this, but I can't make a router with a ".php" in the path, so I can't create a router page for
oldapge.php, and then do a redirect from inside the router.
The next suggestion is to let the user hit the 404 page, build the new URL there, and then use Wix's location.to to redirect to the new page, but this also isn't a great solution because the 404 happens, and is returned in the network response. Also, the 404 page shows up while the page code is running, and then we are redirected to the correct page.
I'd like to actually use a 301. There are benefits in terms of search engines that I need.
Is there a way to do this?