Social Icons

Pages

Thursday, June 6, 2013

Yii URL Management

Yii allows to customize your url
Eg: http://localhost/liveYii/index.php?r=User/admin
change to
http://localhost/liveYii/User/admin

You have to do edit the files

1) protected/config/main.php

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

2) .htaccess

RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(images|js)
# otherwise forward it to index.php
RewriteRule . index.php