Home / Yii / How to remove index.php and ?r= in Yii Framework

How to remove index.php and ?r= in Yii Framework

Hi guys in this article you are going to see “How to remove index.php and ?r= in Yii Framework”

we have already seen how to download and Install Yii Framework in earlier tutorials

Do these 3 steps:

Enable Url re-writing on Apache.
Place .htaccess on root of your project


RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

 

In your configuration protected/config/main.php set showScriptName to false like this to your url manager components >> urlManager


'urlManager'=>array(
 'urlFormat'=>'path',
 'rules'=>array(
 '<controller:\w+>/<id:\d+>'=>'<controller>/view',
 '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
 '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
 ),
 'showScriptName'=>false,
)

About Mohammad Fareed

Software Engineer @ Tekzenit.

Check Also

Yii Framework – Generate Models, Controllers and Views

Yii Framework – Generate Models, Controllers and Views Post Views: 80

Leave a Reply

Your email address will not be published. Required fields are marked *