| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/bpkd_/ |
Upload File : |
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /bpkd/
# =====================================================
# HAPUS index.php DARI URL
# =====================================================
# Redirect /index.php ke /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /bpkd/index\.php\ HTTP/
RewriteRule ^index\.php$ /bpkd/ [R=301,L]
# =====================================================
# REDIRECT KE HTTPS (WAJIB UNTUK KEAMANAN)
# =====================================================
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/bpkd/$1 [R=301,L]
# =====================================================
# HAPUS TRAILING SLASH
# =====================================================
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [R=301,L]
# =====================================================
# HAPUS EKSTENSI .php UNTUK FRONTEND (DIPERBAIKI)
# =====================================================
# Redirect requests without .php to the .php file
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/.]+)/?$ $1.php [L]
# Untuk file dengan parameter (contoh: berita?page=1)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/.]+)/([0-9]+)/?$ $1.php?page=$2 [L,QSA]
# =====================================================
# ARTIKEL dengan HASH & SLUG (DIPERBAIKI PRIORITAS)
# =====================================================
# HASH (prioritas lebih tinggi karena spesifik)
RewriteRule ^artikel/([a-zA-Z0-9]{10,32})$ detail-artikel.php?hash=$1 [L,QSA,NC]
# SLUG (tanpa angka di awal)
RewriteRule ^artikel/([a-z0-9][a-z0-9_-]+)$ detail-artikel.php?slug=$1 [L,QSA,NC]
# =====================================================
# HALAMAN STATIS (DIPERBAIKI DENGAN VALIDASI)
# =====================================================
# Hanya prefix yang valid
RewriteRule ^(profil|ppid|dokumen|halaman|layanan)/([a-zA-Z0-9_-]+)$ page.php?prefix=$1&slug=$2 [L,QSA,NC]
# =====================================================
# KATEGORI & TAG
# =====================================================
RewriteRule ^kategori/([a-zA-Z0-9_-]+)$ kategori.php?slug=$1 [L,QSA,NC]
RewriteRule ^tag/([a-zA-Z0-9_-]+)$ tag.php?slug=$1 [L,QSA,NC]
# =====================================================
# BERITA & PENGUMUMAN (PAGINATION)
# =====================================================
RewriteRule ^berita$ berita.php [L,QSA]
RewriteRule ^berita/page/([0-9]+)$ berita.php?page=$1 [L,QSA]
RewriteRule ^pengumuman$ announcements.php [L,QSA]
RewriteRule ^pengumuman/page/([0-9]+)$ announcements.php?page=$1 [L,QSA]
RewriteRule ^pengumuman/([0-9]+)/?$ announcement.php?id=$1 [L,QSA]
# =====================================================
# GALERI
# =====================================================
RewriteRule ^galeri$ galeri.php [L,QSA]
RewriteRule ^galeri/([0-9]+)/?$ galeri.php?id=$1 [L,QSA]
RewriteRule ^galeri/page/([0-9]+)$ galeri.php?page=$1 [L,QSA]
# =====================================================
# PENCARIAN (DENGAN VALIDASI)
# =====================================================
RewriteRule ^cari/([a-zA-Z0-9+%_-]+)$ search.php?q=$1 [L,QSA,B,NE]
# =====================================================
# LAPORAN
# =====================================================
RewriteRule ^laporan$ laporan.php [L,QSA]
RewriteRule ^laporan/kategori/([a-zA-Z0-9_-]+)$ laporan.php?kategori=$1 [L,QSA,NC]
# =====================================================
# PROFIL & KONTAK
# =====================================================
RewriteRule ^profil$ profil.php [L,QSA]
RewriteRule ^kontak$ kontak.php [L,QSA]
# =====================================================
# STATIC PAGES (TANPA PREFIX)
# =====================================================
RewriteRule ^(tentang|visi-misi|struktur-organisasi|legalitas)$ page.php?slug=$1 [L,QSA,NC]
# =====================================================
# ADMIN - Jangan rewrite untuk admin
# =====================================================
RewriteRule ^admin($|/) - [L,NC]
# =====================================================
# STATIC ASSETS - Izinkan akses langsung
# =====================================================
RewriteRule \.(css|js|jpg|jpeg|png|gif|ico|svg|woff|woff2|ttf|eot|pdf)$ - [L,NC]
# =====================================================
# 404 HANDLING (DIPERBAIKI)
# =====================================================
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
</IfModule>
# =====================================================
# KOMPRESI GZIP (MENINGKATKAN KECEPATAN)
# =====================================================
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
AddOutputFilterByType DEFLATE application/javascript application/x-javascript application/json
AddOutputFilterByType DEFLATE image/svg+xml application/rss+xml
</IfModule>
# =====================================================
# CACHE CONTROL (MENINGKATKAN PERFORMANCE)
# =====================================================
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/html "access plus 1 day"
ExpiresByType application/pdf "access plus 1 month"
</IfModule>
# =====================================================
# KEAMANAN - HEADERS (DITINGKATKAN)
# =====================================================
<IfModule mod_headers.c>
# Security Headers
Header set X-XSS-Protection "1; mode=block"
Header set X-Content-Type-Options "nosniff"
Header set X-Frame-Options "SAMEORIGIN"
Header set Referrer-Policy "strict-origin-when-cross-origin"
Header set Permissions-Policy "geolocation=(), microphone=(), camera=()"
Header set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; img-src 'self' data:; font-src 'self' https://cdn.jsdelivr.net;"
# Hapus informasi server
Header unset X-Powered-By
Header always unset Server
# Cache untuk assets
Header set Cache-Control "public, max-age=31536000, immutable" "expr=req_uri -strmatch '*.css' || req_uri -strmatch '*.js' || req_uri -strmatch '*.jpg' || req_uri -strmatch '*.png' || req_uri -strmatch '*.webp'"
Header set Cache-Control "private, max-age=0, must-revalidate" "expr=req_uri -strmatch '*.html'"
</IfModule>
# =====================================================
# BLOKIR USER AGENT JAHAT
# =====================================================
<IfModule mod_rewrite.c>
RewriteCond %{HTTP_USER_AGENT} (ahrefs|majestic|rogerbot|semrush|dotbot|bingbot|goget|baiduspider) [NC]
RewriteRule .* - [F,L]
</IfModule>
# =====================================================
# DISABLE DIRECTORY BROWSING
# =====================================================
Options -Indexes
Options +FollowSymLinks
# =====================================================
# PROTECT SENSITIVE FILES
# =====================================================
<FilesMatch "\.(htaccess|htpasswd|ini|log|sh|sql|bak|config|json|xml|env|gitignore|md|txt)$">
Require all denied
</FilesMatch>
# =====================================================
# BLOKIR INCLUDE FILE
# =====================================================
<FilesMatch "^(config|database|functions|init)\.php$">
Require all denied
</FilesMatch>
# =====================================================
# RATE LIMITING (SEDERHANA)
# =====================================================
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{HTTP_COOKIE} !PHPSESSID
RewriteCond %{REQUEST_URI} ^/bpkd/(login|register|kontak)\.php$ [NC]
RewriteCond %{REMOTE_ADDR} ^(.*)$
RewriteCond %{HTTP_USER_AGENT} ^(.*)$
RewriteCond %{ENV:RATELIMIT} ^$
RewriteRule .* - [E=RATELIMIT:1]
</IfModule>
# =====================================================
# ERROR DOCUMENTS
# =====================================================
ErrorDocument 400 /bpkd/400.php
ErrorDocument 401 /bpkd/401.php
ErrorDocument 403 /bpkd/403.php
ErrorDocument 404 /bpkd/404.php
ErrorDocument 500 /bpkd/500.php
ErrorDocument 502 /bpkd/502.php
ErrorDocument 503 /bpkd/503.php