unable to remove index.php in url

Good day,

I'm trying to get index.php removed from the url but for some reason, not able to get it to work. I've already check rewrite_module and set AllowOverride to All but still no go. Below is the .htaccess that i'm using as well as the configuration file for yii.

/** .htaccess **/

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

/** main.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'=&gt;dirname(__FILE__).DIRECTORY_SEPARATOR.'..',


'name'=&gt;'real tax property management system',





// preloading 'log' component


'preload'=&gt;array('log'),





// autoloading model and component classes


'import'=&gt;array(


	'application.models.*',


	'application.components.*',


	'application.extensions.userLib.*',


),





'modules'=&gt;array(


	'gii'=&gt;array(


	'class'=&gt;'system.gii.GiiModule',


	'password'=&gt;'pickupapasswordhere',


	),


),








        


'defaultController'=&gt;'main',





// application components


'components'=&gt;array(


	'user'=&gt;array(


		// enable cookie-based authentication


		'allowAutoLogin'=&gt;true,


	),


	


	


     


     /*'cache'=&gt;array(


                    'class'=&gt;'system.caching.CApcCache',


	 ),


	'db'=&gt;array(


		'connectionString' =&gt; 'sqlite:protected/data/blog.db',


		'tablePrefix' =&gt; 'tbl_',


	),*/


	// uncomment the following to use a MySQL database


	


	'errorHandler'=&gt;array(


		// use 'site/error' action to display errors


        'errorAction'=&gt;'site/',


    ),


    'urlManager'=&gt;array(


    	 	'urlFormat' =&gt; 'path',


        	'showScriptName' =&gt; false,


        	'rules' =&gt; array(        


    			


        	),


    ),


	'log'=&gt;array(


		'class'=&gt;'CLogRouter',


		'routes'=&gt;array(


			array(


				'class'=&gt;'CFileLogRoute',


				'levels'=&gt;'error, warning',


			),


			// uncomment the following to show log messages on web pages


			/*


			array(


				'class'=&gt;'CWebLogRoute',


			),


			*/


		),


	),


)

);

I followed the instructions on this post(http://www.yiiframew…php#entry39541) but still not able to get it to work. Hope you could help me with this one… Thanks

Hi buknoy,

could you please post the path where you stored the .htaccess file? Maybe its located in the wrong directory?

Best regards,

Felix

your .htaccess has to be in the root of your app, the same directory where index.php sits.

did you figure this out? I am having the same issue.

same problem here also.

In windows 7 it is not working… But in ubuntu 12.04 its working perfectly.

main.php code :

‘urlManager’=>array(

		'urlFormat'=&gt;'path',


		'rules'=&gt;array(


		'&lt;controller:&#092;w+&gt;/&lt;id:&#092;d+&gt;'=&gt;'&lt;controller&gt;/view',


		'&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;/&lt;id:&#092;d+&gt;/*'=&gt;'&lt;controller&gt;/&lt;action&gt;',





		'&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;', 


              	


    


		'&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;',


		'&lt;module:&#092;w+&gt;/&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;'=&gt;'&lt;module&gt;/&lt;controller&gt;/&lt;action&gt;',








		),


		'showScriptName'=&gt;false,


	),

In .htaccess file

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond $1 !^(index\.php)

RewriteRule ^(.+)$ index.php?$1 [PT,L,QSA]

For index.php to be removed mod_rewrite should be enabled so check that first.

for me, it is enabled.

Check this links to see if some solution fits your case:

http://www.yiiframework.com/forum/index.php/topic/12547-

http://www.yiiframework.com/forum/index.php/topic/15688-

http://www.yiiframework.com/forum/index.php/topic/39422-

I have made my urls seo friendly by doing the following simple steps,

[b]Step 1:

[/b]

In application root directory create a file named .htaccess, then edit the file in editor and paste the following content in it

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

Note, this rule will allow both of the of urls, with inex.php and without index.php

Step 2,

Now you can also tell yii to not use index.php in url,

For that you need to edit your protected/config/main.php

and in url manager array paste the following line,

‘showScriptName’=>false,

as shown below

‘urlManager’ => array(

        'urlFormat' =&gt; 'path',


        'showScriptName'=&gt;false,


        ......


        );

And that will be all

I have tested it on both windows and linux and it is working fine.

It worked for me follow these instructions

.htaccess file

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

and adding following to my urlManager array

	'urlManager'=&gt;array(


		'urlFormat'=&gt;'path',


                    'showScriptName'=&gt;false,


		'rules'=&gt;array(


			'&lt;controller:&#092;w+&gt;/&lt;id:&#092;d+&gt;'=&gt;'&lt;controller&gt;/view',


			'&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;/&lt;id:&#092;d+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;',


			'&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;',


		),


	),