Today I am going to explain the removal of index.php in Yii framework.
Here are the instructions: 1) Make sure that Apaches Rewrite Module is enabled. It can be enabled using a2enmod command: $ sudo a2enmod rewrite Then restart Apache like: root@Roopz-PC:~# /etc/init.d/apache2 restart 2) Set Apaches AllowOverride to ALL In my case, I am using virtualhost, so thats the file I needed to edit. The part I need to edit looks like this: Options Indexes FollowSymLinks MultiViews #this is the part that needs changing. Change None to All AllowOverride None Order allow,deny allow from all Then again, restart the web server. root@Roopz-PC:~# /etc/init.d/apache2 restart 3) Write the .htaccess file in your web application directory Using your favorite text editor, you may paste this script: 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 4) Edit main.php Using again your favorite text editor, open the main.php under /protected/config folder. Look for the word urlManager (which is commented by default), and uncomment it if necessary. The urlManager part of the file I am editing is untouched, so I uncommented it, and configured it in such a way that it now looks like this:
urlManager => array(
urlFormat => path, showScriptName => false, rules => array( / => /view, // => /, / => /, ), ), Now you can see http://localhost/web/site/contact is working Please do share if you like the post. About the Author: Ravi thanki is a PHP developer working at Rudra Softech. He is having very good experience of 2 years into PHP and Yii applications. Rudra Softech is offshore software development company in Ahmedabad offering development services into PHP and Yii since last 4 years.