Rewrite old PHP-Nuke page links to wordpress links

I had been using an old PHP-Nuke site for the last 6+ years and I finally convert over to WordPress. There are probably 100’s of old links posted on other sites out there that I need to redirect to the new ones.

The old links look like this

Read More
http://www.mysite.com/modules.php?name=NDReviews&op=Story2&reid=387

The new links look like this

http://www.mysite.com/cooler-master-ceres-400-headphones/2/

The two items that change for each old links are the =Story# and the reid=#

The =Story# now needs to point towards the new /#/

while the old reid=# needs to point towards the /new-name-for-review/

Thanks!

Related posts

Leave a Reply

1 comment

  1. I hope you know how to code a simple plugin. This could be the skeleton to start to play:

    add_action('init', 'flushRewriteRules');
    function flushRewriteRules()
    {
        global $wp_rewrite;
        $wp_rewrite->flush_rules();
    }
    
    add_filter('rewrite_rules_array', 'insertMyRewriteRules');
    function insertMyRewriteRules($rules)
    {
        $newrules = array();
    
        // convert:
        // http://www.mysite.com/modules.php?name=NDReviews&op=Story2&reid=387
        // to:
        // http://www.mysite.com/NDReviews/2/
    
        $newrules['modules.php?name=([^&]*)&op=Story(d+)&reid=(d+)'] = 'index.php?pagename=$matches[1]&p=$matches[2]';
    
        // or maybe just redirecting Story# to p=# (post id)
    
        // convert:
        // http://www.mysite.com/modules.php?name=NDReviews&op=Story2&reid=387
        // to:
        // http://www.mysite.com/cooler-master-ceres-400-headphones/2/
    
        $newrules['modules.php?name=([^&]*)&op=Story(d+)&reid=(d+)'] = 'index.php?&p=$matches[2]';
    
        return $newrules + $rules;
    }
    

    Is just an idea to experiment a possible solution. In any case is totally achievable.