-
-
Notifications
You must be signed in to change notification settings - Fork 404
Open
Description
On https://statamic.dev/static-caching#apache it shows .htaccess rules for redirecting to the static files. I believe the order these lines is wrong and therefore never hits the actual cache files.
This is in the docs:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} !live-preview
RewriteRule ^ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} live-preview
RewriteRule ^ index.php [L]
RewriteCond %{DOCUMENT_ROOT}/static/%{REQUEST_URI}_%{QUERY_STRING}\.html -s
RewriteCond %{REQUEST_METHOD} GET
RewriteRule .* static/%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]
</IfModule>
I kept receiving this message in Laravel logs:
Static cache loaded [..url..] If you are seeing this, your server rewrite rules have not been set up correctly.
I changed it to this, and now the message does not show up anymore:
<IfModule mod_rewrite.c>
RewriteCond %{DOCUMENT_ROOT}/static/%{REQUEST_URI}_%{QUERY_STRING}\.html -s
RewriteCond %{REQUEST_METHOD} GET
RewriteRule .* static/%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} !live-preview
RewriteRule ^ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} live-preview
RewriteRule ^ index.php [L]
</IfModule>
I also added the missing IfModule starting tag. I would happily make a merge request, but I wanted to check if I am not missing something obvious as I don't see any issues raised by other users about this.
benlilley
Metadata
Metadata
Assignees
Labels
No labels