How to remove index.php from URL

Hi Draz,

I am getting the same error. Did you resolve your 404 error?? if yes please let me know the solution.

Thank you.

I got the 404 error solved. I had to make a little change to my httpd.conf …

<Directory "C:/Apache/htdocs">

#


# Possible values for the Options directive are &quot;None&quot;, &quot;All&quot;,


# or any combination of:


#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews


#


# Note that &quot;MultiViews&quot; must be named *explicitly* --- &quot;Options All&quot;


# doesn't give it to you.


#


# The Options directive is both complicated and important.  Please see


# http://httpd.apache.org/docs/2.2/mod/core.html#options


# for more information.


#


Options Indexes FollowSymLinks





#


# AllowOverride controls what directives may be placed in .htaccess files.


# It can be &quot;All&quot;, &quot;None&quot;, or any combination of the keywords:


#   Options FileInfo AuthConfig Limit


#

AllowOverride All

#


# Controls who can get stuff from this server.


#


Order allow,deny


Allow from all	

</Directory>

Though i had AllowOverride set to ‘All’ for all directories, above directory pointing to htdocs override AllowOverride to None, so i was not able to get rid of index.php in URI… Now changed it to ALL… Everything is working like a Gem…

Thank you.

HBK

If it’s not working even after putting all those rewrite rules in the .htacsses file, please check the .htacsses file location because by default it is located inside /protected folder.

.htacsses should be in the root location.

Hi

i changed my main.php

‘urlManager’=>array(

		'urlFormat'=&gt;'path', 'showScriptName'=&gt;false,


		'rules'=&gt;array(


			'Home'=&gt;'site/index',


			'&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;',


		),


	),

but error showing that "Not Found"

I think this may be the piece you may have been missing. This in the httpd.conf file.

how can hide index.php

edit webapp/protected/.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

and use ‘showScriptName’=>false, in config/main

iapply these changes on localhost and

after these changes index.php has been hide but when we click on other links then that links are not working

there is not found error is occurred

1.I think you must have not restarted your Apache Services. Check if there’s a tick mark on it now. If not it is still not enabled.

2.I have successfully removed index.php (Both on Local and Windows Server). Place this file in the root directory.Same level as of "Protected folder".Find my .htacess code below :




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




  1. Now config\main.php. Find my code below :




		'urlManager'=>array(

			'urlFormat'=>'path',

			'showScriptName'=>false,    //Add This Line

			'caseSensitive'=>false,     //Add This Line

			

			'rules'=>array(

			

				/*Home Page Start*/    

				'' => 'site/index',     //Note: See below

				/*Home Page End*/


                         ...

                         )..



NOTE : If your URL Management is successful, then you will not see site/index in your home url. As you can see in the above code, we have made it blank “’’=‘site/index’”

HOPE THIS HELPS!! Cheers to YII. :D

I know this is an old topic, but for me since the Yii app was under a subdirectory, the redirect wouldn’t work.

The fix was to include this line in the htaccess:




RewriteBase /



You might need to change the / to something else.

I hope this would be better


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/site/$1 

#RewriteRule ^(.*)$ index.php?r=site/$1 

#RewriteRule ^(.*)$ index.php/$1 [L] 

#RewriteRule ^(.*)$ /index.php/$1 [L]   

RewriteRule . index.php 

RewriteRule ^([a-z0-9\-]+)/$ index.php 

 AddOutputFilterByType DEFLATE text/html text/xml text/css text/javascript

uncomment url forwarding one by one to fit your requirement ;D