refereshing empty page issue has fixed

This commit is contained in:
akash 2025-12-06 13:49:16 +05:30
parent 0e50297231
commit 1d22961058

View File

@ -2,49 +2,35 @@
RewriteEngine On RewriteEngine On
RewriteBase / 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} !-f
RewriteCond %{REQUEST_FILENAME} !-d 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 # Apache 404 (Next.js static export supports 404.html)
RewriteCond %{REQUEST_URI} ^(.+)/$ ErrorDocument 404 /404.html
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]
</IfModule> </IfModule>
# Set proper MIME types <IfModule mod_headers.c>
<IfModule mod_mime.c> # Cache static assets aggressively
AddType text/html .html <FilesMatch "\.(js|css|png|jpg|jpeg|gif|ico|svg|webp)$">
AddType application/javascript .js Header set Cache-Control "public, max-age=31536000, immutable"
AddType text/css .css </FilesMatch>
AddType image/webp .webp
AddType image/svg+xml .svg
</IfModule>
# Enable compression # HTML is not cached (important for updated content)
<IfModule mod_deflate.c> <FilesMatch "\.(html)$">
AddOutputFilterByType DEFLATE text/html text/plain text/css application/javascript application/json image/svg+xml Header set Cache-Control "public, max-age=0, must-revalidate"
</IfModule> </FilesMatch>
# 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"
</IfModule> </IfModule>