Home

How to hide index.php in the url in a Yii website

Published on 3/30/2011


to hide “index.php” from the url on a website, add an .htaccess file to your web root, with this text:

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 in /protected/config/main.php, set:

‘urlManager’=>array(
‘urlFormat’=>‘path’,
   ‘showScriptName’=>false,
   ‘caseSensitive’=>false,

... views