Migrate Drupal Seo Urls


Am migrating around 100k node from Drupal 6 to Yii, all working fine, but am meeting problem with SEO urls, the best solution am thing about is to create a table which include node id, Drupal seo url.

The Yii will compare node id to the old slug, if it exist then will view the node, else check only the node id and view the content …

How ?



You could use in urlManager, rules something like that








For 100k node … will take ages to finish it …

old : url.com/content/article-slug-the-article-title

new: url.com/article/article-new-slug-or-same

You could create the accosiative array dynamically from your database.

Another solution:

check this

Thanks, I will check it … I knwo is can be generated with query & foreach … but its will 100k line ^^

What I need is actionBeforView(); will check the sites if its in table article or no, if no then will check in another table where new node id is reflected to the old slug …

You can search in the table according to the current slug-url request,

so, it is no required to consume to much data on memory. (so check the posted article)

Then what will best way ?

moving without this I will lose search engines indexing …

I would do it like this:

  1. store slugs in same table with content

  2. create urlManager custom rule class that will catch only existing slugs (read: http://www.yiiframework.com/doc/guide/1.1/en/topics.url#using-custom-url-rule-classes)

  3. put custom rule as one of first matched in urlManager

the custom rule should check if provided url matches any slug and return proper module/controller/action route to your controller and action that will get controll. Action should take the route (slug) and fetch proper record from db according to the slug…

I will give it try … Thanks

ended with the following … working fine, but is this best way ??

// components/UrlRule.php

class UrlRule extends CBaseUrlRule{

    public $connectionID = 'db';


    public function createUrl($manager,$route,$params,$ampersand){

        return true;


    public function parseUrl($manager,$request,$pathInfo,$rawPathInfo)


		$params = explode("/", $pathInfo); // content/slugOfArticle

		if($params[0] == 'content'){

			$Article = Article::model()->findByAttributes(array('slug'=>$params[1]), 'status=1'); 





				//redirect to search page




        return false;  



parseUrl should return route if url is matched and false otherwise so other rules can be matched, so you do not need to call "Yii::app()->request->redirect" but simply:

$Article = Article::model()->findByAttributes(array('slug'=>$params[1]), 'status=1'); 


	return "article/view";

} else {

	return false;


this will pass controll to ArticleController::actionView() which can access Yii::app()->request->getParam( ‘slug’ ) and display the page.

using "redirect" causes request loop (sending "location" header to browser, and then another call to server)

Thanks alot man …