t3k
(Misio321)
July 4, 2011, 9:02am
1
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?
Redjik
(Rej)
July 4, 2011, 9:33am
2
Read more carefully =)
We then configure the showScriptName property of the urlManager component to be false.
t3k
(Misio321)
July 4, 2011, 10:44am
3
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]
t3k
(Misio321)
July 4, 2011, 4:52pm
5
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.
softark
(Softark)
July 4, 2011, 10:24pm
6
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’.
phtamas
(Phtamas)
July 4, 2011, 10:50pm
7
'showScriptName'=>'false',
should be
'showScriptName'=>false,
(without quotes)
t3k
(Misio321)
July 5, 2011, 7:37am
8
Yup it works now. Thanks.