Kamis, 05 Februari 2015

Menghilangkan index.php pada url codeigniter di web server centos 6.5

,
Secara default URL codeigniter akan tampil "domain/index.php/controller", agar lebih enak dilihat (menurut pendapat saya saja sih) perlu menghilangkan "index.php" di URL tersebut. Berikut langkah-langkahnya.

  1. masuk ke dirctory website secara default "/var/www/html/" buka "application/config/config.php".
  2. Update code $config['index_page'] = 'index.php'; menjadi $config['index_page'] = '';  (hilangkan index.php).
  3. Buat file .htaccess di root directory website (bukan root directory server), didalam file .htaccess  masukan script berikut :
  4. # .htaccess file
    RewriteEngine On
    # Removes index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]
    
  5. Buka "/etc/httpd/conf/httpd.conf", cari file berikut :
  6. pastikan di "AllowOverride All". Jika sudah restart servis httpd, lalu jalankan website.
Read more →