url management

I have remove index.php from my url’s like specified in the definitive guide to Yii Link

But if I use CMenu links I still get redirected to pages with index.php at the beginning of urls.

So e.g. if I use this code:

$this->widget(‘zii.widgets.CMenu’,array(

		'items'=>array(


			array('label'=>'Home', 'url'=>array('/home/')),


		),


	));

users that clicks this links goes to: index.php/home instead of what I want that is just /home.

What I have to do to remove index.php from the urls in CMenu?

Read more carefully =)

We then configure the showScriptName property of the urlManager component to be false.

It is false. This is how my configuration looks like:

	'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',


	),

Have you created the .htaccess file in the root of the project. It should read something like this:




Options +FollowSymLinks

IndexIgnore */*

RewriteEngine on


# if a directory or a file exists, use it directly

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d


# otherwise forward it to index.php

RewriteRule ^.*$ /index.php [L]




My .htaccess file looks like this:

RewriteEngine on

if a directory or a file exists, use it directly

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

otherwise forward it to index.php

RewriteRule . index.php

All of it I have from the tutorial mentioned above.

What is the route (controller/action) for your "Home"?

If it is the default action of the default controller, then




    array('label'=>'Home', 'url'=>array('/')),



should do.

Otherwise, you have to give the proper route for ‘url’.


'showScriptName'=>'false',

should be


'showScriptName'=>false,

(without quotes)

Yup it works now. Thanks.