Wednesday, March 21, 2012

Remove ?r= on Link URL Web Application Yii Framework

To get rid of ?r= the url link web pages on Yii Framework application then you need to do is remove the tag comment on the path-format URLs.

Example url before changed
http://localhost/webappname/index.php?r=site/index
Having changed
http://localhost/webappname/index.php/site/index

  1. Open the protected/main.config.php
  2. Find the following code
    /*
      'urlManager'=>array(
       'urlFormat'=>'path',
       'rules'=>array(
        '/'=>'/view',
        '//'=>'/',
        '/'=>'/',
       ),
      ),
      */
    In the code above we can see there is still a tag comment / * and * /
  3. Remove the tag comment / * and * /
    'urlManager'=>array(
       'urlFormat'=>'path',
       'rules'=>array(
        '/'=>'/view',
        '//'=>'/',
        '/'=>'/',
       ),
      ),
  4. Completed, please reload the page and see your web application url link.
Yii Framework Tutorials