111 lines
No EOL
4 KiB
ApacheConf
111 lines
No EOL
4 KiB
ApacheConf
# DATEI: ./.htaccess
|
|
Options -Indexes
|
|
RewriteEngine On
|
|
|
|
# HTTP Security Headers
|
|
<IfModule mod_headers.c>
|
|
Header always set X-Frame-Options "SAMEORIGIN"
|
|
Header always set X-Content-Type-Options "nosniff"
|
|
Header always set Referrer-Policy "strict-origin-when-cross-origin"
|
|
</IfModule>
|
|
|
|
# MIME-Types für moderne Web-Assets
|
|
<IfModule mod_mime.c>
|
|
AddType font/woff2 .woff2
|
|
AddType font/woff .woff
|
|
AddType image/webp .webp
|
|
AddType image/svg+xml .svg .svgz
|
|
</IfModule>
|
|
|
|
# Performance: Gzip-Kompression (mod_deflate)
|
|
<IfModule mod_deflate.c>
|
|
AddOutputFilterByType DEFLATE text/plain
|
|
AddOutputFilterByType DEFLATE text/html
|
|
AddOutputFilterByType DEFLATE text/xml
|
|
AddOutputFilterByType DEFLATE text/css
|
|
AddOutputFilterByType DEFLATE text/javascript
|
|
AddOutputFilterByType DEFLATE application/xml
|
|
AddOutputFilterByType DEFLATE application/xhtml+xml
|
|
AddOutputFilterByType DEFLATE application/rss+xml
|
|
AddOutputFilterByType DEFLATE application/javascript
|
|
AddOutputFilterByType DEFLATE application/x-javascript
|
|
AddOutputFilterByType DEFLATE application/json
|
|
AddOutputFilterByType DEFLATE image/svg+xml
|
|
AddOutputFilterByType DEFLATE font/opentype
|
|
AddOutputFilterByType DEFLATE font/otf
|
|
AddOutputFilterByType DEFLATE font/ttf
|
|
</IfModule>
|
|
|
|
# Performance: Browser-Caching (mod_expires & mod_headers)
|
|
<IfModule mod_expires.c>
|
|
ExpiresActive On
|
|
ExpiresDefault "access plus 1 month"
|
|
|
|
# Webfonts (1 Jahr)
|
|
ExpiresByType font/woff2 "access plus 1 year"
|
|
ExpiresByType font/woff "access plus 1 year"
|
|
ExpiresByType font/ttf "access plus 1 year"
|
|
ExpiresByType font/otf "access plus 1 year"
|
|
ExpiresByType application/font-woff2 "access plus 1 year"
|
|
|
|
# Bilder & Icons (1 Monat bis 1 Jahr)
|
|
ExpiresByType image/x-icon "access plus 1 year"
|
|
ExpiresByType image/vnd.microsoft.icon "access plus 1 year"
|
|
ExpiresByType image/webp "access plus 1 month"
|
|
ExpiresByType image/png "access plus 1 month"
|
|
ExpiresByType image/jpeg "access plus 1 month"
|
|
ExpiresByType image/gif "access plus 1 month"
|
|
ExpiresByType image/svg+xml "access plus 1 month"
|
|
|
|
# CSS & JavaScript (1 Woche)
|
|
ExpiresByType text/css "access plus 1 week"
|
|
ExpiresByType application/javascript "access plus 1 week"
|
|
ExpiresByType text/javascript "access plus 1 week"
|
|
|
|
# HTML & dynamische Daten nicht aggressiv cachen
|
|
ExpiresByType text/html "access plus 0 seconds"
|
|
</IfModule>
|
|
|
|
<IfModule mod_headers.c>
|
|
<FilesMatch "\.(ico|jpe?g|png|gif|webp|svg|woff2?|ttf|otf)$">
|
|
Header set Cache-Control "public, max-age=31536000, immutable"
|
|
</FilesMatch>
|
|
<FilesMatch "\.(css|js)$">
|
|
Header set Cache-Control "public, max-age=604800, stale-while-revalidate=86400"
|
|
</FilesMatch>
|
|
</IfModule>
|
|
|
|
# Interne PHP-, Vendor- und Template-Verzeichnisse vor direktem Webzugriff sperren
|
|
RewriteRule ^(home|philcore)/(app|core|views|src)/ - [F,L]
|
|
RewriteRule ^(.*/)?vendor/ - [F,L]
|
|
|
|
# Sensible Dateien und Verzeichnisse vor direktem Webzugriff schützen
|
|
<FilesMatch "(^\.|\.(json|lock|sql|env|md)$)">
|
|
Require all denied
|
|
</FilesMatch>
|
|
|
|
# Interne Hilfsdateien vor direktem Aufruf schützen
|
|
<FilesMatch "^(auth\.php|db\.php|google_helper\.php)$">
|
|
Require all denied
|
|
</FilesMatch>
|
|
|
|
# 1. Assets aus home/public weiterleiten (falls direkt aufgerufen wie /css/style.css)
|
|
RewriteCond %{REQUEST_FILENAME} !-f
|
|
RewriteCond %{DOCUMENT_ROOT}/home/public/$1 -f [OR]
|
|
RewriteCond %{DOCUMENT_ROOT}/home/public/$1 -d
|
|
RewriteRule ^(.*)$ home/public/$1 [L]
|
|
|
|
# 2. Dynamische XML/TXT Dateien -> Ab zum SeoController
|
|
RewriteRule ^sitemap\.xml$ home/public/index.php?url=seo/sitemap [L,QSA]
|
|
RewriteRule ^robots\.txt$ home/public/index.php?url=seo/robots [L,QSA]
|
|
|
|
# 3. Domain-Einstieg
|
|
RewriteRule ^$ home/public/index.php [L]
|
|
|
|
# 4. Echte Verzeichnisse/Dateien im Root (dinos, plants, etc.) direkt bedienen
|
|
RewriteCond %{REQUEST_FILENAME} -f [OR]
|
|
RewriteCond %{REQUEST_FILENAME} -d
|
|
RewriteRule ^ - [L]
|
|
|
|
# 5. Globales Routing ans Portfolio
|
|
RewriteRule ^(.*)$ home/public/index.php?url=$1 [L,QSA] |