Skip to content

Instantly share code, notes, and snippets.

@themorgantown
Created September 19, 2025 18:38
Show Gist options
  • Save themorgantown/1626a64f3bf171319ee31b0feb2a7160 to your computer and use it in GitHub Desktop.
Save themorgantown/1626a64f3bf171319ee31b0feb2a7160 to your computer and use it in GitHub Desktop.
Htaccess file for a Simply Static Export (assuming you're using relative urls during export and your static files have been uploaded to a /static/ folder). You can keep wordpress running in that root dir and just swap this in...
# Enable URL rewriting
RewriteEngine On
# Force HTTPS redirect
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Redirect ALL requests to the static directory
# Check if the requested file exists in /static/ first
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/static%{REQUEST_URI} -f
RewriteRule ^(.*)$ /static/$1 [L]
# If file doesn't exist in /static/, try with .html extension
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/static%{REQUEST_URI}.html -f
RewriteRule ^(.*)$ /static/$1.html [L]
# Default homepage redirect to static index.html
RewriteRule ^/?$ /static/index.html [L]
# Fallback: redirect everything else to /static/ (even if file doesn't exist)
# This ensures all requests go to static directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /static/$1 [L]
# Set default document for directory requests
DirectoryIndex index.html index.htm
# Optional: Set caching headers for static assets
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment