I’m having the same problem. I have following the “Special Topics” documentation, but “index” still appears in the URL.
My .htaccess:
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 my /protected/config/main.php, urlManager is set to:
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'caseSensitive'=>true,
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
If I enter into the browser:
http://somewhere.com/controller?somevar=123
it works as expected (displayed actionIndex()).
Also, entering into the browser:
http://somewhere.com/controller/index/somevar/123
works as expected.
However, when I create an URL with a parameter using createUrl, like so:
$url = Yii::app()->createUrl('controller/index', array('somevar' => 123));
then the URL displayed in the browser is:
http://somewhere.com/controller/index?somevar=123
This is not desirable. What else needs to be done to remove "index" from the URL so that the above example would be:
http://somewhere.com/controller/somevar/123
when using createUrl?