1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| # Redirect all HTTP traffic to HTTPS <VirtualHost *:80> ServerName example.com ServerAlias www.example.com
# Log files for redirect ErrorLog /var/log/apache2/example.redirect.error.log CustomLog /var/log/apache2/example.redirect.access.log combined
# Redirect everything to https://example.com RewriteEngine On RewriteRule ^ https://example.com%{REQUEST_URI} [L,R=301] </VirtualHost>
# Redirect www → non‑www over HTTPS <VirtualHost *:443> ServerName www.example.com
# SSL certificates SSLEngine on SSLCertificateFile /home/sync-user/example/SSL/live/example.com/fullchain.pem SSLCertificateKeyFile /home/sync-user/example/SSL/live/example.com/privkey.pem
# Log files ErrorLog /var/log/apache2/example.www-redirect.error.log CustomLog /var/log/apache2/example.www-redirect.access.log combined
# Redirect to non‑www RewriteEngine On RewriteRule ^ https://example.com%{REQUEST_URI} [L,R=301] </VirtualHost>
# Serve Flutter Web App with HTTPS <VirtualHost *:443> ServerName example.com
# SSL certificates SSLEngine on SSLCertificateFile /home/sync-user/example/SSL/live/example.com/fullchain.pem SSLCertificateKeyFile /home/sync-user/example/SSL/live/example.com/privkey.pem
# Log files for app ErrorLog /var/log/apache2/example.error.log CustomLog /var/log/apache2/example.access.log combined
DocumentRoot /home/sync-user/example/html DirectoryIndex index.html
<Directory /home/sync-user/example/html> Options -Indexes +FollowSymLinks AllowOverride None Require all granted
# Fallback routing for SPA RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ /index.html [L] </Directory>
# Ensure proper MIME type for WebAssembly AddType application/wasm .wasm
# Cache static assets for 30 days <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/x-icon "access plus 30 days" ExpiresByType text/css "access plus 30 days" ExpiresByType application/javascript "access plus 30 days" ExpiresByType image/gif "access plus 30 days" ExpiresByType image/jpeg "access plus 30 days" ExpiresByType image/png "access plus 30 days" ExpiresByType image/svg+xml "access plus 30 days" ExpiresByType font/woff2 "access plus 30 days" ExpiresByType application/font-woff "access plus 30 days" ExpiresByType application/vnd.ms-fontobject "access plus 30 days" ExpiresByType font/ttf "access plus 30 days" ExpiresByType font/otf "access plus 30 days" </IfModule> <IfModule mod_headers.c> <FilesMatch "\.(?:ico|css|js|gif|jpe?g|png|svg|woff2?|ttf|eot|otf)$"> Header set Cache-Control "public, immutable, max-age=2592000" </FilesMatch> </IfModule> </VirtualHost>
|