45 lines
1.4 KiB
ApacheConf
45 lines
1.4 KiB
ApacheConf
|
|
# 301 Redirects for SEO
|
||
|
|
RewriteEngine On
|
||
|
|
|
||
|
|
# Force HTTPS
|
||
|
|
RewriteCond %{HTTPS} off
|
||
|
|
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
|
||
|
|
|
||
|
|
# Force www
|
||
|
|
RewriteCond %{HTTP_HOST} !^www\.
|
||
|
|
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
|
||
|
|
|
||
|
|
# Remove trailing slash
|
||
|
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||
|
|
RewriteCond %{THE_REQUEST} /+[^?\s]*?/[\s?]
|
||
|
|
RewriteRule ^(.+)/$ /$1 [R=301,L]
|
||
|
|
|
||
|
|
# Handle React Router
|
||
|
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||
|
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||
|
|
RewriteRule . /index.html [L]
|
||
|
|
|
||
|
|
# 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/webp "access plus 1 year"
|
||
|
|
</IfModule>
|
||
|
|
|
||
|
|
# Compress files
|
||
|
|
<IfModule mod_deflate.c>
|
||
|
|
AddOutputFilterByType DEFLATE text/plain
|
||
|
|
AddOutputFilterByType DEFLATE text/html
|
||
|
|
AddOutputFilterByType DEFLATE text/xml
|
||
|
|
AddOutputFilterByType DEFLATE text/css
|
||
|
|
AddOutputFilterByType DEFLATE application/xml
|
||
|
|
AddOutputFilterByType DEFLATE application/xhtml+xml
|
||
|
|
AddOutputFilterByType DEFLATE application/rss+xml
|
||
|
|
AddOutputFilterByType DEFLATE application/javascript
|
||
|
|
AddOutputFilterByType DEFLATE application/x-javascript
|
||
|
|
</IfModule>
|