Jumat, 18 Oktober 2013

Cara Hapus Index.php Di YII Framework


Untuk menghilangkan index.php pada url ada beberapa konfigurasi yang perlu dilakukan, antara lain setting main.php yang ada di folder config. Kemudian merubah showScriptName menjadi false pada urlManager. Untuk lebih jelasnya lihat script dibawah ini.
1
2
3
4
5
6
7
8
9
'urlManager'=>array(
    'urlFormat'=>'path',
    'showScriptName'=>false,
    'rules'=>array(
        '<controller:\w+>/<id:\d+>'=>'<controller>/view',
        '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
        '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
    ),
),
Buat file .htaccess dan letakkan pada folder root. Berikut isi dari file .htaccess
1
2
3
4
5
6
7
8
9
10
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# ganti nama web aplikasi anda di bawah ini
RewriteBase /nama_web_aplikasi/
# 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
WARNING: pada file .htaccess perhatikan baris ke-5 sesuaikan RewriteBase dengan direktori anda, jika ada di root (aplikasi bukan dalam folder) maka anda cukup RewriteBase /
Semoga informasi ini bermanfaat bagi anda.

Comments :

ada 0 komentar ke “Cara Hapus Index.php Di YII Framework”

Posting Komentar

 
Google - Date : - Reviewer by Aldi - Rating :5