Thursday, June 22, 2017

Remove index.php from URL in CodeIgniter Framework

By default you will get index.php in the url of your CodeIgniter website like the following line
http://yoursite.com/index.php/blog/
You can hide this from the url using a very simple method. At first open config.php and do following replaces
$config['index_page'] = "index.php"
to
$config['index_page'] = ""
Now create a htaccess file in the root directory of your project and paste the following code.
.htaccess
Options +FollowSymLinks 
Options -Indexes 
DirectoryIndex index.php 
RewriteEngine on 
RewriteCond $1 !^(index\.php|assets|images|css|js|install|robots\.txt|favicon\.ico) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

How to practice tutorials…

  • Make a team with your friends (Member should be 4/5).
  • Start to practice one tutorial series along with them.
  • Don’t try to collect source code. Type the code while watching the tutorial.
  • If you face any problem, post the question in the Forum with the error codes.
  • Share that question Link with your friends or team members to solve quickly.
  • Discuss the problem in the Forum along with others - Video Guidelines.