Hi to everyone
I’m looking for a solution to transform the Yii url from the standard format
http://localhost/<nome_sito>/index.php?r=site/index
into a more SEO friendly format, like:
http://localhost/<nome_sito>/site/index
In config/main.php I’ve this
'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>',
),
),
In protected/views/layouts/main.php I use this code to call the pages
$this->widget('zii.widgets.CMenu',array(
'items'=>array(
array('label'=>'Home', 'url'=>array('/site/index')),
array('label'=>'Ricerca','url'=>array('/site/ricerca')),
array('label'=>'Servizi', 'url'=>array('/site/page', 'view'=>'about')),
array('label'=>'Contatti', 'url'=>array('/site/contact')),
//array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
//array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)
),
));
Now the actual problem is that when I try to go to some of those pages the link
the adress I got is this http://localhost/<nome_sito>/index.php/controlle/action
So I’ve modified the .htacces ( but I didn’t understand if I need to modify the htaccess in the yii folder or the one in my local server).
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
In this way I was able to overwrite the index.php in the adress, but when I click on one of the pages in the menu
above I got an apache error 404, that the page doesn’t exist on my local server.
There’s something that I need to change in my menu widget?
I need to use baseUrl to call the correct location of the pages?
Another thing when I see the website with index.php in the adress, I can’t see images.
Thanks in advace to everyone.