Mengaktifkan File .htaccess Pada Apache2 di Linux Ubuntu

Untuk mengetahui salah satu manfaat dari file .htaccess silahkan baca artikel sebelumnya yang memanfaatkan fungsi dari file .htaccess :

Nah, ketika anda menggunakan XAMPP for windows sebagai paket server  maka file .htaccess akan bisa langsung berfungsi begitu pula ketika anda menginstal apache di windows , namun sebaliknya ketika anda menggunakan linux dalam hal ini ubuntu sebagai sistem operasi dan apache2 sebagai web server, maka file .htaccess secara default tidak bisa berjalan dengan baik (tidak aktif), ketika anda memaksakan menjalankan aplikasi web yang menggunakan .htaccess maka akan timbul Internal Error (Error 500) seperti berikut :

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/2.2.14 (Ubuntu) Server at www.smkn2-kng.lcl Port 80

Untuk menghilangkan error ini maka anda harus mengaktifkan file .htaccess dengan cara me-load sebuah modul apache yang menangani file .htaccess yaitu modul mod_rewrite, berikut langkah-langkahnya :

1. jalankan terminal, kemudian load modul mod_rewrite

$sudo a2enmod rewrite

2. Edit file default di direktori /etc/apache2/sites-available

$pico /etc/apache2/sites-available/default

3.  Tambahkan baris diantara directive  <virtualhost *:80> </virtualhost>berikut (bila belum ada)

<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

4. Restart web  server apache

$sudo /etc/init.d/apache2 restart

5. Dan coba anda download salah satu contoh dari artikel tentang pemanfaatan file .htaccess pada blog ini, Insya Allah berjalan normal

Post a Comment

Previous Post Next Post