Hilangkan Index.php Dari URL Framework Codeigniter 3

Silahkan masuk kedalam folder project anda, kemudia bukalah folder application, lalu masuk ke folder config. Carilah file config.php seperti pada di bawah ini.


/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = 'index.php';

Kemudian hapus index.php, sehingga akan seperti dibawah ini


/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';

lalu buat file .htaccess didalam folder root project anda dan copykan script dibawah ini!


#Hapus index.php
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]

Pastikan file .htaccess terletak di folder root project anda. berikut adalah gambaran struktur tabel lokasi file .htaccess diletakan


- [Folder project anda]
	- application
	- assets
	- system
	- .htaccess
	- index.php

Ali Akbar

Software Developer yang fokus mengembangkan aplikasi berbasis Web dan Desktop. Senang mempelajari teknologi baru terutama di bidang web design dan web development.

View all posts by Ali Akbar →

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *