Iam newbie to YII framework and using its latest vesion 1.1.0. I have enabled seo friendly urls through config file. My next problem is that how can I remove 'index.php' from URL. Iam using following .htaccess file.
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
<?php
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Web Application',
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
),
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
// uncomment the following to enable URLs in path-format
'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>',
),
),
'db'=>array(
'connectionString' => 'sqlite:protected/data/testdrive.db',
),
// uncomment the following to use a MySQL database
/*
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=testdrive',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
),
*/
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
/*
array(
'class'=>'CWebLogRoute',
),
*/
),
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'webmaster@example.com',
),
);
This usually means, that AllowOverride is set to None for this directory (or one of its parents directories) in your Apache config, which means: Do not allow to override settings in a .htaccess file.
I know this is a year old. But wanted to say itās great thereās a good community here as I look around through the forum. If you had not asked the OP for his config file, the documentation or my interpretation of it had me actually trying to modify files in the framework to get this to work.After reading this I looked at the config file and saw the code already auto generated and commented out. Both the tour videos and the first couple chapters of the new yii book say it is easy to do but they donāt tell how to do it. Frustrating but glad thereās an active community. Iām really liking Yii since I started this morning.
To remove āindex.phpā from your URLs we need to tell the server to parse all files as though they did have āindex.phpā in the URL, but just not show it to the user.
I enabled the url manager and the index.php part in the url gets removed and works fin
my .htacsses file
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php)
# otherwise forward it to index.php
RewriteRule ^(.+)$ index.php?$1 [PT,L,QSA]
the url manager works fine ut index.php doesnāt go away in the url
so I added when I have showScriptName set to false in my config/main.php file