Tuesday, 10 April 2012

Yii SEO hide url parameter's name using CUrlManager

For Yii framework: SEO


For SEO, we want our url can be as short, clear, nifty as possible. but how to optimize our url which contains lots of control parameters?


If you use Yii Framwork for your project, CUrlManager is is the trick to achieve that goal!


E.g., if the url is formatted as : 


www.xxx.com/controller/action/id/idvalue/time/timevalue/trace/tracevalue


Using the following config, the request can be made as follows: 


www.xxx.com/controller/action/idvalue/timevalue/tracevalue


In your PHP, you simply use $_GET['id'],$_GET['time'],$_GET['trace']....to get corresponding values! 


The trick: Pls add this rule to your main.php:


'rules'=>array('controller/action/<id>/<time>/<trace>' => 'controller/action')

2 comments:

  1. Bloggers, Please try this one and share your comments. "Sozialpapier" is an interest based network. It connects you to the favorite articles, authors and interests. http://sozialpapier.com .

    ReplyDelete
  2. This topic is very useful for me, thanks

    web designing

    ReplyDelete