How Can Create Url Seo As Opencart

Could you tell me how can I create SEO URL as opencart by use CController::forward()?

Here my example.

class ProductController extends Controller


        public function actionShow($id){


                $product = Product::model()->find(....);

                render('show', array('product' => $product));



class Controller extends CController


        public function BeforeAction($action){

		$action = Product::model()->find('slug=:s', array(':s' => 'this-is-seo-url-product'));


			$this->forward('product/show', array('id' => $action->id))






My problem is a loop at beforeAction() and it cannot forward to action of controller I want.

Please take a minute to help me!

Thank you so much!

you can use URl Management to create SEO friendly url

For your product controller, simply add a new url rule in Yii’s config file (ie. main.php in config folder)

'product/<id:[\w-]+>' => 'product/show',

Which will create following url

And to allow more character in url, change the rule as following

'product/<id:[a-zA-Z0-9_\-\.]+>' => 'product/show',

Source : http://www.yiiframew…king-url-suffix