I am converting a custom built site into a WordPress site. Unfortunately, the custom site has a completely different URL structure, which we would like to set up 301 redirects for. The site receives upwards of 300k unique visitors per month, therefore we wish to minimise the loss of traffic - especially the articles linked to from major news sites throughout the World.

So, an example of a URL is as follows:-


There are a total of around 30 categories (including parent and child), but close to 11,000 articles.

I was thinking we could use the cNewsArti values as the 'post_slug' which would be easily imported into WP. However, this would still leave difficult in the remainder of the string, as we will likely use the following WP permalink:-


My thoughts are this would produce:-


So, how could I do the rest of the redirection? As you can gather, creating custom 301's for 11,000 articles is probably out of the equation.

Any ideas?

Thanks in advance!

Edit:- The data has already been imported into the WordPress database, which all works OK - we assigned all posts to a bunch of random categories to ensure everything works in Wordpress as expected, no problems found.

  • How are you planning on importing all of your content from the old site and setting the proper categories?
    – Milo
    Nov 25, 2015 at 20:18
  • Did you find a solution for your problem?
    – jgraup
    Dec 10, 2015 at 22:12

3 Answers 3


One option is to Add URL Rewrite Rules.

Create an API Endpoint in WordPress is a good tutorial as well as The Rewrite API: The Basics.

Monkeyman Rewrite Analyzer is a great way to test what you created. Just be sure to flush your permalinks after each change.

This is also a good example which uses the endpoint to redirect elsewhere.

The biggest trick will be to get your ID for each post on the old site into a form which can be used on the new site.


Rather than use any of the old data in the new URL structure, I would instead save the old cNewsArti value in post meta for each post so you can look those posts up by that value.

You can then hook init, check if cNewsArti is passed, and query for a post with that matching value in post meta data. If the post is found, do a 301 redirect to its new permalink.

function wpd209890_old_url_redirect(){
    if( isset( $_GET['cNewsArti'] ) ){
        $query = new WP_Query(
                'meta_query' => array(
                        'key'     => 'cNewsArti',
                        'value'   => $_GET['cNewsArti']
        if( isset( $query->post ) ){
            wp_redirect( get_permalink( $query->post->ID ), 301 );
add_action( 'init', 'wpd209890_old_url_redirect' );

I like the suggestions. I thought of another problem, however, which means we will likely have to use the cNewsArti values as the post_name value - the site is in Korean language. Post titles, excerpts and content - all Korean. Therefore I don't think we can use the Korean article titles for the post name - .com/범주/하위 카테고리/포스트-이름 likely would cause problems, right?

  • This should be an edit to your question. Or, if you meant to address a specific person, add a comment under their answer.
    – Gabriel
    Nov 26, 2015 at 1:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.