Conditional redirects for 404.php page (1 post)

  1. Shane Gowland
    Posted 4 years ago #

    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?

    <script language="JavaScript">
    var time = 100
    function move_1() {
    window.location = 'http://newsite.com/page1/'
    <script language="JavaScript">
    var time = 100
    function move_2() {
    window.location = 'http://newsite.com/page2/'
    <?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...

    Thanks for any help or pointers.

    *I've excluded theme code, obviously

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.