.htaccess Generator

Generate file .htaccess untuk Apache web server. Templates untuk redirect, force HTTPS, WordPress security, caching rules, dan konfigurasi hosting lainnya. Download atau copy langsung.

Penting:

Backup file .htaccess lama Anda sebelum mengganti. File .htaccess yang salah dapat menyebabkan website error atau tidak dapat diakses.

# Generated by PenasihatHosting.com - .htaccess Generator
# Generated on: 

# ====================================
# Disable Directory Listing
# ====================================

Options -Indexes

# End of .htaccess file
11 lines

Apa itu .htaccess?

.htaccess (Hypertext Access) adalah file konfigurasi untuk Apache web server yang memungkinkan Anda mengontrol berbagai aspek website seperti redirects, security headers, caching rules, dan URL rewriting. File ini sangat penting untuk shared hosting yang mayoritas menggunakan Apache.

Fitur .htaccess Generator

  • 6 Template Siap Pakai - WordPress Security, Force HTTPS, WWW Redirect, Browser Caching, GZIP Compression, Custom Error Pages
  • Custom Redirects - Buat unlimited redirect rules (301/302) untuk halaman yang dipindah atau dihapus
  • Multi-Template - Gabungkan beberapa template sekaligus sesuai kebutuhan website Anda
  • Download & Copy - Download langsung sebagai file .htaccess atau copy ke clipboard
  • Documented Code - Semua rules dilengkapi dengan comments yang jelas untuk kemudahan maintenance

Template yang Tersedia

WordPress Security

Proteksi file-file penting WordPress dari akses unauthorized.

  • • Protect wp-config.php (file konfigurasi database)
  • • Protect .htaccess itu sendiri
  • • Block bad bots dan scrapers
  • • Prevent direct access ke file PHP

Force HTTPS

Redirect semua HTTP traffic ke HTTPS secara otomatis.

  • • SEO benefit (Google ranking factor)
  • • Security untuk user data
  • • Prevent mixed content warnings
  • • Required untuk modern web features (PWA, Service Workers)

WWW Redirect

Standardisasi domain dengan atau tanpa www prefix.

  • • Force WWW: example.com → www.example.com
  • • Remove WWW: www.example.com → example.com
  • • Prevent duplicate content issues (SEO)
  • • Consistent brand presence

Browser Caching

Set cache expiry headers untuk file static assets.

  • • Images: 1 tahun (jarang berubah)
  • • CSS/JS: 1 bulan (update berkala)
  • • Fonts: 1 tahun (sangat stabil)
  • • Faster page load untuk repeat visitors

GZIP Compression

Compress file sebelum dikirim ke browser untuk bandwidth saving.

  • • Reduce file size 60-80%
  • • Faster page load time
  • • Lower bandwidth usage
  • • Better Core Web Vitals score

Custom Error Pages

Redirect error codes ke custom error pages yang user-friendly.

  • • 404 Not Found → /404.html
  • • 403 Forbidden → /403.html
  • • 500 Internal Server Error → /500.html
  • • Better UX dengan error pages yang branded

Kapan Menggunakan .htaccess?

Migrasi Website

Redirect old URLs ke new URLs untuk maintain SEO ranking dan user bookmarks.

WordPress Installation

Tambahkan security rules untuk protect wp-config, wp-admin, dan file-file critical.

SSL Certificate Setup

Force HTTPS setelah install SSL certificate untuk redirect semua traffic ke HTTPS.

Performance Optimization

Enable browser caching dan GZIP compression untuk improve page load speed.

Best Practices

⚠️

Always Backup First

Backup file .htaccess yang lama sebelum upload yang baru. File .htaccess yang salah dapat menyebabkan website tidak dapat diakses (500 Internal Server Error).

Test in Staging First

Jika memungkinkan, test .htaccess di staging environment dulu sebelum apply ke production. Atau gunakan online .htaccess tester.

📝

Add Comments

Generator ini sudah menambahkan comments, tapi Anda bisa tambahkan custom comments untuk dokumentasi lebih baik.

🔍

Check Server Logs

Setelah upload, check server error logs untuk memastikan tidak ada error. Biasanya ada di cPanel → Error Logs.

Troubleshooting

500 Internal Server Error

Penyebab: Syntax error di .htaccess atau module Apache yang required tidak aktif.
Solusi: Restore backup .htaccess lama, atau hapus .htaccess sementara untuk akses website. Check error log untuk detail error.

Redirect Loop

Penyebab: Konflik antara .htaccess redirect dan server configuration.
Solusi: Review redirect rules, pastikan tidak ada circular redirect. Kadang perlu koordinasi dengan hosting provider untuk server-level config.

Rules Tidak Berfungsi

Penyebab: Module Apache (mod_rewrite, mod_expires, mod_deflate) tidak aktif.
Solusi: Contact hosting provider untuk enable module yang diperlukan. Shared hosting biasanya sudah enable by default.

FAQ

Dimana lokasi file .htaccess?

File .htaccess biasanya berada di root directory website (public_html atau www). File ini hidden file (diawali titik), jadi pastikan aktifkan "Show Hidden Files" di file manager atau FTP client.

Apakah .htaccess berfungsi di semua hosting?

.htaccess hanya berfungsi di Apache web server. Jika hosting Anda menggunakan Nginx atau LiteSpeed, configuration berbeda (nginx.conf atau .litespeed_conf). Tapi mayoritas shared hosting di Indonesia menggunakan Apache.

Perbedaan redirect 301 vs 302?

301 = Permanent redirect (untuk halaman yang dipindah permanen), pass SEO juice ke URL baru. 302 = Temporary redirect (untuk maintenance), tidak pass SEO juice. Untuk migrasi, gunakan 301.

Apakah .htaccess memperlambat website?

Minimal impact jika digunakan dengan benar. Bahkan dengan browser caching dan GZIP compression, .htaccess justru mempercepat website. Hindari regex yang terlalu complex di rewrite rules.