Okay, PHP and MODx pros -- I have a fun one for you to figure out
I have a site that uses a very inflexible, proprietary content management system. In fact, it’s so inflexible that we were unable to achieve the homepage design we wanted without using Flash, which isn’t a viable option for several reason. So, to get around this problem, I built a second homepage within MODx, and on the homepage of the first site (the bad CMS), I’ve set up a redirect to the second homepage (the MODx one). In other words, typing in www.example1.com will automatically take you to www.example2.com. It’s not a perfect solution, but it was the best option for our situation.
Now, here’s where I need help. This setup actually works really well, except when someone is on www.example2.com and decides to type the address for a subdirectory that would actually be on the first site. So, if they’re trying to go to www.example1.com/subdirectory but don’t notice the first part of the address as they type, they end up with www.example2.com/subdirectory. This page doesn’t exist, and they hit a 404.
What I’m wondering is, would there be a way to take the address they input, swap out www.example2.com for www.example.com, and redirect them to that correct page? Because we’re only running a few pages on the MODx site, I’m comfortable with using my 404 page for this, if necessary. My idea is a snippet that would sit on the 404 page, and when it’s hit, do the address-changing and redirecting, similar to how FirstChildRedirect works.
I know this is a little out of the norm, but it would be a huge help if someone could come up with a solution for this. I am not a PHP expert, so I don’t think I can code the snippet myself. I’d also be fine with a Javascript-based solution if someone has an idea in that direction.
Thanks!