Hey guyz i am a newbie in Yii framework. I want to remove the index.php from my urls. F
If you also want to remove /index
from the main page URL, add ''=>'site/index'
to the top of your urlManager rules, like so:
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName' => false,
'rules'=>array(
''=>'site/index',
'<action>'=>'site/<action>',
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
'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, )
I just came across this thread but found that in order to get it working I not only had to follow the instrucitons for adding the .htaccess file but also had to uncomment the section below from my main config file (\protected\config\main.php):
// uncomment the following to enable URLs in path-format
'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>',
),
),
modify apache config values
AllowOverride none to AllowOverride ALL
in httpd.conf or httpd-vhosts.conf
I had also this problem today when I have shifted my project to linux server. I did all ways that are shown, but not helped. Then, I have copied .htaccess file to protected directory also, then it worked.
Try this
A good description is available here
http://www.yiiframework.com/doc/guide/1.1/en/topics.url#hiding-x-23x