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

[xml]

RewriteEngine on

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

RewriteRule . index.php

[/xml]

 

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

[php]

‘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,
)

[/php]

Add a Comment

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