refereshing empty page issue has fixed
This commit is contained in:
parent
0e50297231
commit
1d22961058
@ -2,49 +2,35 @@
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
|
||||
# Don't rewrite files or directories that exist
|
||||
# Allow Next.js static files and assets
|
||||
RewriteRule ^_next/ - [L]
|
||||
RewriteRule ^static/ - [L]
|
||||
|
||||
# Serve existing files or directories directly
|
||||
RewriteCond %{REQUEST_FILENAME} -f [OR]
|
||||
RewriteCond %{REQUEST_FILENAME} -d
|
||||
RewriteRule ^ - [L]
|
||||
|
||||
# Redirect extensionless URLs to trailing slash directories
|
||||
# Works with "trailingSlash: true" and static export
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_URI} !/$
|
||||
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}/index.html -f
|
||||
RewriteRule ^(.+)$ /$1/ [R=301,L]
|
||||
|
||||
# For URLs with trailing slash, try to serve index.html from that directory
|
||||
RewriteCond %{REQUEST_URI} ^(.+)/$
|
||||
RewriteCond %{DOCUMENT_ROOT}%1/index.html -f
|
||||
RewriteRule ^(.+)/$ /$1/index.html [L,QSA]
|
||||
|
||||
# For URLs without trailing slash, redirect to trailing slash version
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_URI} !(.*)/$
|
||||
RewriteRule ^(.*)$ $1/ [L,R=301]
|
||||
|
||||
# Fallback to 404 page
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule . /404.html [L]
|
||||
# Apache 404 (Next.js static export supports 404.html)
|
||||
ErrorDocument 404 /404.html
|
||||
</IfModule>
|
||||
|
||||
# Set proper MIME types
|
||||
<IfModule mod_mime.c>
|
||||
AddType text/html .html
|
||||
AddType application/javascript .js
|
||||
AddType text/css .css
|
||||
AddType image/webp .webp
|
||||
AddType image/svg+xml .svg
|
||||
</IfModule>
|
||||
<IfModule mod_headers.c>
|
||||
# Cache static assets aggressively
|
||||
<FilesMatch "\.(js|css|png|jpg|jpeg|gif|ico|svg|webp)$">
|
||||
Header set Cache-Control "public, max-age=31536000, immutable"
|
||||
</FilesMatch>
|
||||
|
||||
# Enable compression
|
||||
<IfModule mod_deflate.c>
|
||||
AddOutputFilterByType DEFLATE text/html text/plain text/css application/javascript application/json image/svg+xml
|
||||
</IfModule>
|
||||
|
||||
# Browser caching
|
||||
<IfModule mod_expires.c>
|
||||
ExpiresActive On
|
||||
ExpiresByType text/html "access plus 0 seconds"
|
||||
ExpiresByType text/css "access plus 1 year"
|
||||
ExpiresByType application/javascript "access plus 1 year"
|
||||
ExpiresByType image/webp "access plus 1 year"
|
||||
ExpiresByType image/svg+xml "access plus 1 year"
|
||||
ExpiresByType image/png "access plus 1 year"
|
||||
ExpiresByType image/jpeg "access plus 1 year"
|
||||
# HTML is not cached (important for updated content)
|
||||
<FilesMatch "\.(html)$">
|
||||
Header set Cache-Control "public, max-age=0, must-revalidate"
|
||||
</FilesMatch>
|
||||
</IfModule>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user