# ============================================ # GLOBAL FRONT CONTROLLER FOR EXWEB # ============================================ DirectoryIndex ex.php RewriteEngine On RewriteBase / # ============================================ # KEAMANAN # Harus di atas aturan lain: aturan bertanda [L] di bawah menghentikan # pemrosesan, sehingga blokir yang diletakkan setelahnya tidak pernah jalan. # ============================================ # Folder kode aplikasi & folder kerja tidak boleh diakses langsung RewriteRule ^(core|vendor|config|models|controllers|routes|inc|cache|tests|static-site)(/|$) - [F,L] RewriteRule ^(api|back)/(routes|views)(/|$) - [F,L] # File & folder tersembunyi (.git, .env, dll.), kecuali .well-known untuk verifikasi SSL RewriteRule (^|/)\.(?!well-known/) - [F,L] # File skrip tidak boleh dijalankan dari folder upload/media RewriteRule ^(img|uploads)/.*\.(php[0-9]?|phtml|phar|phps|pht|cgi|pl|py|sh)$ - [F,L,NC] # File konfigurasi, template instalasi, dan data sensitif Require all denied Order allow,deny Deny from all Options -Indexes # ============================================ # REDIRECT NON-WWW → WWW # ============================================ # Uncomment dua baris di bawah jika ingin memaksa WWW (opsional). RewriteCond ikut dikomentari: kondisi yang # dibiarkan aktif menempel ke RewriteRule berikutnya (bypass berkas statis), sehingga berkas statis di host www # tidak lagi dilewatkan. # RewriteCond %{HTTP_HOST} !^www\. [NC] # RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # ============================================ # BYPASS STATIC FILES # ============================================ RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] # ============================================ # SITEMAP DINAMIS # Sesudah bypass berkas statis: sitemap.xml unggahan (File Uploader) didahulukan, # sitemap.php hanya dipakai bila berkas itu tidak ada (sama dengan router.php dan ex.php). # sitemap.xsl dilayani bypass di atas. # ============================================ RewriteRule ^sitemap\.xml$ sitemap.php [L] # ============================================ # API → /api/ex.php # ============================================ RewriteRule ^api/(.*)$ api/ex.php [QSA,L] # ============================================ # INTERNAL ROUTING → FRONT ex.php # ============================================ RewriteRule ^ ex.php [QSA,L] # ============================================ # PERFORMANCE # ============================================ Header unset X-Powered-By AddOutputFilterByType DEFLATE text/plain text/html text/xml application/json text/css text/javascript application/javascript