Add optional URL rewrite config (.htaccess dan nginx.conf.example)

This commit is contained in:
mwpn
2025-12-18 11:36:30 +07:00
parent d130cde84d
commit 12c0c84b20
2 changed files with 133 additions and 0 deletions

61
.htaccess Normal file
View File

@@ -0,0 +1,61 @@
# Apache URL Rewrite untuk Retribusi Frontend
# Opsional: Hanya diperlukan jika ingin clean URLs atau SPA routing
# Enable rewrite engine
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Redirect trailing slash (optional)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [R=301,L]
# Jika ingin clean URLs (tanpa .html), uncomment di bawah:
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^dashboard$ public/dashboard/dashboard.html [L]
# RewriteRule ^event$ public/dashboard/event.html [L]
# RewriteRule ^settings$ public/dashboard/settings.html [L]
# Fallback untuk SPA (jika diperlukan di masa depan)
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
# Security headers
<IfModule mod_headers.c>
# Prevent clickjacking
Header set X-Frame-Options "SAMEORIGIN"
# XSS Protection
Header set X-XSS-Protection "1; mode=block"
# Content Type Options
Header set X-Content-Type-Options "nosniff"
</IfModule>
# CORS untuk development (jika diperlukan)
# <IfModule mod_headers.c>
# Header set Access-Control-Allow-Origin "*"
# Header set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
# Header set Access-Control-Allow-Headers "Content-Type, Authorization, X-API-KEY"
# </IfModule>
# Cache static assets
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
</IfModule>
# Gzip compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json
</IfModule>