icon logo wibloog.comWibloog
  • Teknologi
  • Otomotif
    Motor
    Mobil
  • Gadget
    Smartphone
    Apps
  • Tips dan Ulasan
  • Olah Raga
  • Fashion
  • Pendidikan
  • Kuliner
  1. Home
  2. Informasi Tentang Teknologi dan Komputer

  3. Tutorial

Cara Mengaktifkan Apache Mod_Rewrite di Ubuntu Server 20.04
  • 26 Agustus 2020
  • 759
  • Admin@Wibloog
  • Picture by : #

Cara Mengaktifkan Apache Mod_Rewrite di Ubuntu Server 20.04

Mod_rewrite adalah salah satu modul Apache yang sangat powerful untuk memanipulasi URL, kebutuhan ini dapat digunakan pada .htaccess pada sebuah web server, secara default Apache tidak mengaktiftkan mod_rewrite, sehingga kita harus melakukan beberapa ubahan agar web yang kita bangun berjalan sesuai dengan yang kita inginkan.

Modul mod_rewrite memudahkan kita untuk menyesuaikan url pada sebuah website, agar url yang digunakan terlihat rapi, bersih dan SEO friendly.

Berikut dibawah ini, cara bagaimana mengaktifkan modul mod_rewrite Apache di Ubuntu Server 20.04


1. Aktifkan Mod_Rewrite

Pertama sekali, silakan buka terminal, kemudian aktifkan mod_rewrite seperti dibawah ini.

$ sudo a2enmod rewrite

Selanjutnya Anda harus melakukan restart servis apache

$ sudo /etc/init.d/apache2 restart

Maka sekarang apache yang digunakan sudah aktif untuk menerima rewrite

2. Konfigurasi Site Enable

Step selanjutnya adalah melakukan ubahan pada site-enable pada Apache, agar bisa melakukan URL rewrite yang di jalankan oleh .htaccess

$ sudo nano etc/apache2/site-enabled/000-default.conf

Dibawah ini adalah default isi dari 000-default.conf Apache di Ubuntuk Server 20.04

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf        

</VirtualHost>

Kemudian silakan tambahkan permission direktori pada /var/www/html dibawah ini.

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

Setelah di tambahkan kode permission diatas, maka akan menjadi seperti dibawah ini.

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf

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

</VirtualHost>

Setelah itu simpan dengan menekan tombol keluar Ctrl + x, untuk menyimpan tekan tombol Y (Yes), kemudian silakan restart apache web server.

$ sudo /etc/init.d/apache2 restart

3. Buat .htaccess Sederhana

Silakan buat file .htaccess sederhana, untuk menguji modul mod_rewrite di Apachenya berjalan atau tidak.

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteRule ^kontak$ kontak.html [L]
</IfModule>

Kemudian simpan di folder var/www/html projek atau latihan Anda.

Selanjutnya silakan buat file kontak.html, kemudian simpan di var/www/html, lalu panggil url http://ipaddress/kontak atau menggunakan http://localhost/kontak, jika menggunakan root folder di dalam var/www/html/nama_folder silakan saja tambakan setelah localhost atau ipaddressnya.

Demikian tutorial ini kami bagikan, Terima kasih telah berkunjung di artikel kami, Semoga bermanfaat

Artikel Terbaru

Alternatif Pasang Internet untuk Rumahan
Teknologi dan Komputer 06 Maret 2021
Apakah Jumlah Kata Mempengaruhi Faktor Kualitas Blog
Tips dan Ulasan 05 Maret 2021
Tantangan Berat Jadi seorang Blogger
Tips dan Ulasan 01 Maret 2021
Cara Membuat Pencarian Multiple Keyword di PHP Mysql
Teknologi dan Komputer 27 Februari 2021
Cari tahu Dari Mana Penghasilan Seorang Blogger
Tips dan Ulasan 26 Februari 2021
Realita Bersepeda di Jalan Perkotaan
Olahraga 22 Februari 2021
Realita Jadi Seorang Programmer
Teknologi dan Komputer 20 Februari 2021
Cara Beli Tiket Kereta Api di Bukalapak
Tips dan Ulasan 16 Februari 2021
7 Kelebihan iPhone Dibanding Ponsel Android
Gadget 14 Februari 2021

Komentar

Tinggalkan Komentar Disini


Artikel Terkait

Alternatif Pasang Internet untuk Rumahan
Alternatif Pasang Internet untuk Rumahan
Cara Membuat Pencarian Multiple Keyword di PHP Mysql
Cara Membuat Pencarian Multiple Keyword di PHP Mysql
Realita Jadi Seorang Programmer
Realita Jadi Seorang Programmer
Iklan Web Hosting Dewaweb Lucu
Iklan Web Hosting Dewaweb Lucu
Blog Tanpa SEO Apakah Bisa Page One Google?
Blog Tanpa SEO Apakah Bisa Page One Google?
Cara Logout Gmail Dari Device yang Pernah Digunakan
Cara Logout Gmail Dari Device yang Pernah Digunakan
Kenapa Saya Pilih Linux, Berikut ini Ulasannya
Kenapa Saya Pilih Linux, Berikut ini Ulasannya
Alasan Kenapa Banyak Orang Pakai Blogspot Untuk Cari Uang di Internet
Alasan Kenapa Banyak Orang Pakai Blogspot Untuk Cari Uang di Internet
Kenapa Backup Data Server itu Penting, Berikut ini Ulasannya
Kenapa Backup Data Server itu Penting, Berikut ini Ulasannya
Tribunnews Selalu Menduduki Halaman satu Google, Bagaimana Bisa?
Tribunnews Selalu Menduduki Halaman satu Google, Bagaimana Bisa?
Rekomendasi Macbook Bekas Tahun 2021 dengan Budget Minim
Rekomendasi Macbook Bekas Tahun 2021 dengan Budget Minim
Cara Buat Daftar Pustaka Otomatis Pakai Mendeley
Cara Buat Daftar Pustaka Otomatis Pakai Mendeley
Cara Mudah Verifikasi Domain Google Search Console Hosting Cpanel
Cara Mudah Verifikasi Domain Google Search Console Hosting Cpanel
Perkembangan Google dan Logo dari Generasi Pertama Hingga Sekarang
Perkembangan Google dan Logo dari Generasi Pertama Hingga Sekarang
10 Tips Penting SEO Gambar Yang Perlu Anda Ketahui
10 Tips Penting SEO Gambar Yang Perlu Anda Ketahui

Jasa Buat Blog

Tentang Kami

Wibloog adalah portal informasi yang memuat sebuah artikel yang mengulas tentang perangkat komputer, gadget, teknologi, motor, mobil, fashion, pendidikan, kuliner

Lebih Lanjut ...

Informasi Situs

Kontak
Disclaimer
Sitemap
Jasa Buat Blog
Facebook
DMCA.com Protection Status wibloog.com

© 2019 Wibloog. All Rights Reserved