
How to remove "index.php" and also wants to remove "?r=". I want to make URLs user friendly.
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,
)
1) enable your urlManager in protected>>config>>main.php by adding these line to the array:
'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,
),
2) The .htaccess file should be in the site root in the same of index.php level and should be like that:
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php)
# otherwise forward it to index.php
RewriteRule ^(.+)$ index.php?$1 [PT,L,QSA]
3) make sure that your Apache configuration AllowOverride All not None