Redirect Otomatis dari http ke https

Redirect Otomatis dari http ke https

Untuk masalah keamanan kita bisa memaksa user yang menggunakan http ke webserver kita untuk di redirect otomatis ke https, yaitu dengan menambahkan opsi berikut di httpd.conf

RewriteEngine on
RewriteCond %{SERVER_PORT} =80
RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI}

Kemudian untuk mengaktifkan modul rewrite di apache pastikan juga apache telah load modulnya yaitu dengan baris berikut

# rule-based rewriting engine to rewrite requested URLs on the fly
LoadModule rewrite_module      /usr/lib/apache/modules/mod_rewrite.so

setelah itu nyalakan ulang apachenya

apachectl restart

Setelah itu maka setiap koneksi yang diarahkan ke http maka akan secara otomatis di redirect menuju alamat https, dan pastikan juga https telah berjalan dengan baik di webserver anda.

  1. oh….ho oh bagus2, perjuangankan terus anak muda..

  2. bwt line ini:

    https://%{SERVER_NAME}%{REQUEST_URI}

    apa diisi dengan webserver kita?

  3. @rundie:
    tidak, server name nanti otomatis merujuk ke variable server name di apache kita, dan request_url nanti menujuk ke url itu sendiri yang dituju si client

  4. mas nama qu juga Rifqi
    Aqu anak Kediri salam kenal yoo
    N…. ajari aku ngeblog mas yo..
    add E-mail aq yo..
    please ajari aq Ngeblog
    di a.rifqi@yahoo.com

  5. btw men, itu konfig

    RewriteEngine on
    RewriteCond %{SERVER_PORT} =80
    RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI}

    ditaro setelah load LoadModule rewrite_module
    baru bisa jalan

Reply to Harry ¬
Cancel reply


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>