My wordpress urls where governed by http://wordpress.org/extend/plugins/scategory-permalink (Select Category) and the path was defined with "/%scategory%/%postname%/"

So now I get 404s in drupal :(

Don't see a way around it :(

Comments

eiland’s picture

Status: Active » Closed (fixed)

i fixed it myself using phpmyadmin and the path_redirect module.

Using phpmyadmin on my wp db

SELECT DISTINCT wp_terms.term_id, wp_postmeta.post_id, term3.slug, term2.slug, term1.slug, wp_terms.slug, wp_posts.post_name, wp_posts.post_title

FROM wp_postmeta
LEFT JOIN wp_posts ON wp_postmeta.post_id=wp_posts.ID
LEFT JOIN wp_terms ON wp_postmeta.meta_value=wp_terms.term_id
LEFT JOIN wp_term_taxonomy ON wp_term_taxonomy.term_id = wp_terms.term_id
LEFT JOIN wp_terms AS term1 ON term1.term_id = wp_term_taxonomy.parent
LEFT JOIN wp_term_taxonomy AS tax1 ON tax1.term_id = term1.term_id
LEFT JOIN wp_terms AS term2 ON term2.term_id = tax1.parent
LEFT JOIN wp_term_taxonomy AS tax2 ON tax2.term_id = term2.term_id
LEFT JOIN wp_terms AS term3 ON term3.term_id = tax2.parent
WHERE wp_postmeta.meta_key = "_category_permalink"

The results I edited with my spreadsheet editor OOo calc to read

$title["old_path"]="post title";

and use the the following php snippet to create the mysql to import into drupal:

	$dbhost = 'localhost';
	$dbuser = 'user';
	$dbpass = 'passwrd';
	$dbname = 'db';

	$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

	mysql_select_db($dbname);

	$title["old_path"]="post title";
	(...)

	echo "<table>";

	foreach ($title as $path => $name)
	{
	$name=mysql_real_escape_string($name);

	$query = 'SELECT * FROM `node` 
	left join url_alias on url_alias.src=CONCAT("node/",node.nid)
	WHERE node.`title` = "'.$name.'"';

	$queryresult=mysql_query($query);

	if ($row=mysql_fetch_assoc($queryresult))
	{
	echo '<tr>INSERT INTO path_redirect set source="'.$path.'", redirect="'.
	$row['dst'].'", type=301, query="", fragment="" ;<br></td></tr>';
	} 
	}
	

of which i fed the results in he path_redirect table (obviously this module needs to be activated).

Voila.

A similar construction you can use to redirect Wordpress category pages to drupal taxonomy term pages. You just need to alter the above mysql code to extract the Wordpress category paths and titles, an the sql in the php to get the new term path from drupal.

sorry if code looks a mess, but it works fine :)