Selasa, 23 Januari 2018

codeIgniter, removing index.php in url

source : https://situsali.com/belajar-codeigniter-3-dasar-routing/

The default URL used by CI contains "index.php". This bothers some of us.
So here is how I remove the "index.php" inside the URL.


  • Make sure mod_rewrite module in Apache is already activated. This can be checked in httpd.conf. This file can be found in xampp/apache/conf/httpd.conf. Find a line with this LoadModule rewrite_module modules/mod_rewrite.so. If there is a hashtag at the beginning of the line, remove it. 
  • Restart Apache, if it is necessary 
  • Create a .htaccess file inside the CI folder, at the same level with application directory, system directory, user_guide directory and so on. 
  • Insert this code inside .htaccess: 
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

  • Finally, go to application/config/config.php. Set the value of $config['index_page'] to '' (blank) --> $config['index_page'] = '';

That's it

Tidak ada komentar:

Posting Komentar