Conditional redirects for 404.php page
-
I’m currently moving all pages and content for my website to an assortment of other sites. The old will become a portal which directs users in the right direction.
Since pages are going to be removed, it is likely that a number of links will return the 404.php file in my theme. I need a way of conditionally redirecting users to the correct page on the new websites. I was thinking something like this*, however it is a little bit messy. Are there any more effective ways of doing it?
<html> <head> <script language="JavaScript"> var time = 100 function move_1() { window.location = 'https://newsite.com/page1/' } //--> </script> <script language="JavaScript"> var time = 100 function move_2() { window.location = 'https://newsite.com/page2/' } //--> </script> </head> <?php if (is_page('page1')) { echo "<body onload=\"timer=setTimeout(\'move_1()\',2000)\">"; } elseif (is_page('page2')) { echo "<body onload=\"timer=setTimeout(\'move_2()\',2000)\">"; } else { echo "<body>"; } ?> You are being redirected to the new page... </body> </html>
Thanks for any help or pointers.
*I’ve excluded theme code, obviously
- The topic ‘Conditional redirects for 404.php page’ is closed to new replies.