Pengaturan .Htaccess di Linux

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
    $ sudo pico /etc/apache2/sites-available/default
3.  Edit seluruh directive AllowOverride None menjadi AllowOverride All
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

No comments:

Post a Comment