Redirecting Drupal ?q=/node/ to WordPress item (8 posts)

  1. Anonymous
    Posted 8 years ago #

    Hi all,

    I'm about to do the big switch from Drupal to WordPress. I have a handful of popular Drupal nodes that I'd like to have redirect to their WordPress equivalent. Could someone share with me the best way to put together an .htaccess file that could accomplish this?


  2. tsguitar
    Posted 8 years ago #

    Search for .htaccess in Google for how to set up rules for redirection. I found this very quickly:

  3. Anonymous
    Posted 8 years ago #

    I've been searching all day and that was the first link I found. Unfortunately a simple re-direct in the .htaccess won't do the trick here since the parameter ?q=node/## needs to be converted to ?p=## on the WordPress side.

  4. Same root directory? If the numbers line up (good luck with that :) ) try

    RewriteRule ^?q=node/(.*) http://your.blogurl.com/?p=$1 [R=301,L]

    If the numbers are different (such as drupal number is 17 and WordPress post number is 54) try this

    RewriteRule ^?q=node/17 http://your.blogurl.com/?p=54 [R=301,L]

    Give that a shot and good luck.

    PS. Backup, backup, backup your .htaccess file on the off chance you fat finger something...

  5. Adrian Diaconescu
    Posted 8 years ago #

    I have a similar problem. jdembowski, if I try your code like this:

    RewriteRule ^?q=services http://my.blogurl.com/services [R=301,L]

    I get a 500 Internal Server Error. If I add the "/" like this:

    RewriteRule ^/?q=services http://my.blogurl.com/services [R=301,L]

    it takes me to the homepage. Any ideas? I also tried this:

    RedirectMatch permanent ^/?q=services$ http://my.blogurl.com/services

    but got the same result.

  6. dlambert@appdev.info
    Posted 8 years ago #

    I've got one here that seems to work for me. Only took me about eight hours and a couple dozen google searches.

    RewriteCond %{QUERY_STRING} ^q=node/(.+)$
    RewriteRule ^(.*)$ http://www.yoururlhere.com/?p=%1 [R=301,L]

    It turns out that you need the RewriteCond to match the query string - RewriteRule won't do it. Then, in the RewriteRule line, you use %1 instead of $1 to pick up the first match from RewriteCond rather than the match in RewriteRule.

    I'm really glad this finally worked for me, but I really hate working with htaccess.

  7. Joe Hawes
    Posted 7 years ago #

    Thanks to the previous poster, this is EXACTLY what I was after!

  8. GATEKeeper
    Posted 7 years ago #

    I'm having a similar issue, or at least I think I think so.

    I have a gallery that no longer exists and want to forward people coming in to those URLs to the tag for gallery.

    As an example, one URL ends with: '/gallery/displayimage.php?pos=-653'
    And I want to send people to: '/tag/gallery/'

    I've been trying everything, but nothing works. Any suggestions how I can adapt the previous example to work for me?

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.