Files
CodePress/public/.htaccess
T
E.Noorlander c244514a48 Clean URLs and security improvements
- Add .htaccess rewrite rules for clean URLs (/nl/page, /admin/route)
- Add PHP dev server router with clean URL support
- Update admin template asset paths to absolute for clean URL compat
- All pentest fixes verified: CSRF on login, directory listing disabled,
  secure cookies, backup/sourcemap files removed, version disclosure off
2026-07-14 15:28:53 +02:00

64 lines
1.8 KiB
ApacheConf

# Disable directory listing
Options -Indexes
# Security - Block sensitive files
<Files ~ "^\.">
Require all denied
</Files>
<FilesMatch "\.(ini|log|conf|config|map)$">
Require all denied
</FilesMatch>
<FilesMatch "\.(backup|bak|old|orig|swp|save)$">
Require all denied
</FilesMatch>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Admin routes: /admin/login → admin.php?route=login
RewriteRule ^admin$ admin.php?route=dashboard [L,QSA]
RewriteRule ^admin/(.+)$ admin.php?route=$1 [L,QSA]
# Language-prefixed page routes: /nl, /en, /nl/page/path
RewriteRule ^(nl|en)/?$ index.php?lang=$1 [L,QSA]
RewriteRule ^(nl|en)/(.+)$ index.php?lang=$1&page=$2 [L,QSA]
# Root
RewriteRule ^$ index.php [L]
# Serve existing static files directly
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
# Block directory listing for remaining physical dirs
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [F]
# Fallback to index.php
RewriteRule ^(.*)$ index.php [L,QSA]
</IfModule>
# Security headers
<IfModule mod_headers.c>
Header always set X-Content-Type-Options nosniff
Header always set X-Frame-Options DENY
Header always set X-XSS-Protection "1; mode=block"
Header always set Referrer-Policy "strict-origin-when-cross-origin"
Header always set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self';"
</IfModule>
<IfModule mod_php.c>
php_flag display_errors Off
php_flag log_errors On
php_value max_execution_time 30
php_value memory_limit 128M
php_value upload_max_filesize 10M
php_value post_max_size 10M
</IfModule>
DirectoryIndex index.php
ErrorDocument 404 /index.php