Redirect joomla url’s to wordpress

I moved an ex-site based on joomla to wordpress. Import worked fine but the problem is that the old links don’t work anymore.
Because there is only 50 or so articles, i thought will be a good idea to put a rule for each post (in .htaccess).

Well… Not always things are like you want, so redirects dont work at all 🙁

Read More

Old joomla links looks like this:

http://site.com/index.php?option=com_content&task=view&id=49&Itemid=29
http://site.com/index.php?option=com_content&task=view&id=42&Itemid=29
http://site.com/index.php?option=com_content&task=view&id=68&Itemid=29

And need to be translated to:

http://site.com/?p=23
http://site.com/?p=24
http://site.com/?p=25
  • basically no relations between old and new links, so i don’t think a regex will help

  • both old and new site are on the same domain

Ok, the problem is that any rule i’ve tried (and i tried a LOT!), none worked. in few cases i get 500 error, but most of times the redirect didn’t work.

So, any of you guys had same problem? I don’t necessary want to have nice permalinks, but if i can, that will be better. The problem is that i have many backlinks to old url’s and i don’t want to loose them.

Thanks a lot guys!

Related posts

Leave a Reply

4 comments

  1. Since the conversion of your site over to WordPress is relatively new, is there anything preventing you from using the old Joomla! ID’s in your WP database table? This would allow you to use a regex fairly easily.

    Another option would be to create a separate PHP script that handles the Joomla! URLs then redirects to the WordPress ones. So you would have a regex in your Apache configuration detecting index.php?option=com_content&task=view URLs, finding the value for ‘id’, then redirecting to someotherscript.php that would have a map of your ids from Joomla! to WordPress. This script would then use header(‘Location: ?p=’ . $id) to redirect to the correct page in WordPress.

  2. Thnaks for the idea! I put this in index.php (wordpres default):

    if(isset($_GET['option'])) {
        if(is_numeric($_GET['id'])){
            header ('HTTP/1.1 301 Moved Permanently');
            header("Location: http://www.site.com/?p={$_GET['id']}");
            die();
        }else {
            die('Hacking attempt');
        }
    }
    

    And works like… GREAT! 😀

  3. I had a very similar issue with some unknown CMS to Joomla.
    If you want to do it with .htaccess in Apache there is a way, but if there is absolute no relation between the old URL and the new URL than you have to write two lines for each URL pair.

    RewriteEngine On
    # now the first Example
    RewriteCond %{QUERY_STRING} ^option=com_content&task=view&id=49&Itemid=29$
    RewriteRule ^index.php$ /?p=23 [R=301,L]
    # Repeat last two lines for all your URLs
    

    I’m not sure if you really have this kind of new URLs. Personally a SEF URL would be better e.g.: https://example.com/path/to/new/page

    If you want to do this than you can do it, but you have to add a ? at the end of the destination otherwise the old Query string would be added to you new destination like this: https://example.com/path/to/new/page?option=com_content&task=view&id=49&Itemid=29
    so for this example do it as follows:

    RewriteCond %{QUERY_STRING} ^option=com_content&task=view&id=49&Itemid=29$
    RewriteRule ^index.php$ /path/to/new/page? [R=301,L]