Sunday 21 April 2013

How to remove / hide index.php from url in yii framework (PHP)

  • remove index.php from url in yii hide index.php from url in yii php url styling php
Just follow steps:

  • Make sure that the hosting / your pc mod_rewrite module is active. if not actively try to activate in a way, open the httpd.conf file. You can check this in the phpinfo.php to find out.
Find line #LoadModule rewrite_module modules/mod_rewrite.so
and remove just '#'

  • Create file .htaccess under directory protected/ or protected/www/ where app's index.php file is hosted and add following code snippet
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

  • Set main.php in your yii configuration, at component :
'urlManager' => array(
                'urlFormat'=>'path',
                'showScriptName'=>false,
                'caseSensitive'=>false,        
               ),

  • Now just hits the your app Url.

No comments:

Post a Comment