I am newbie to Yii framework. I have uncommented the url manager in the config file and got a url scheme like this:
http://localhost/mysite/index.php/displayAll
I don't want the index.php in the url. So I want a url some thing like this
http://localhost/mysite/displayAll
To accomplish this, what should I do. I did play with the url manager and some htaccess, but nothing gone well.
Please help
In your .htaccess you should have this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Then you have to add the urlManager component to your main config file:
array(
......
'components'=>array(
......
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
'pattern1'=>'route1',
'pattern2'=>'route2',
'pattern3'=>'route3',
),
),
),
);
Notice the 'showScriptName'=>false, this will hide 'index.php' from the generated URL.
To find everything about Yii's URL Manager check out this topic in Yii's documentation: http://www.yiiframework.com/doc/guide/1.1/en/topics.url
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With