# FORCE UTF-8 CHARSET FOR ALL HTML, PHP, CSS, JS FILES
AddDefaultCharset UTF-8
AddCharset UTF-8 .html .css .js .php .json .xml

# Tự động nạp index.html khi truy cập thư mục hoặc tên miền gốc
DirectoryIndex index.html index.php

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # 1. Chuyển hướng 301 bỏ "index.html" ở trang chủ (vd: http://tigerhumic.com/index.html -> http://tigerhumic.com/)
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html(\?|\ |\HTTP) [NC]
    RewriteRule ^index\.html$ / [R=301,L,NE]

    # 2. Chuyển hướng 301 bỏ "index.html" ở tất cả các thư mục con (vd: /danh-muc/index.html -> /danh-muc/)
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)/index\.html(\?|\ |\HTTP) [NC]
    RewriteRule ^(.*)/index\.html$ /$1/ [R=301,L,NE]
</IfModule>
