Skip to content

Instantly share code, notes, and snippets.

@jeremyblaze
Created January 15, 2020 23:05
Show Gist options
  • Save jeremyblaze/8dec3fce3852ca9adc1cf679962c582c to your computer and use it in GitHub Desktop.
Save jeremyblaze/8dec3fce3852ca9adc1cf679962c582c to your computer and use it in GitHub Desktop.
Fixes page links on exported Webflow sites
Options -Multiviews -Indexes +FollowSymLinks
DirectorySlash Off
RewriteEngine On
RewriteBase /
# Remove .html at the end of the request
RewriteCond %{THE_REQUEST} "^(GET|POST|HEAD) /(.*).html(\?.*)? HTTP/[0-9.]+$"
RewriteRule ^(.*)\.html $1 [R=301,L]
# Remove trailing slash
RewriteRule ^(.*)/$ $1 [R=301,L]
# Redirect /index to /
RewriteRule ^index$ ? [R=301,L]
# Output .html file content for non-html URLs
RewriteCond ${REQUEST_URI} !^(.*)\.html(\?.*)?$
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)/?$ $1.html [L]
# Special case for folders
RewriteCond ${REQUEST_URI} !^(.*)\.html(\?.*)?$
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)/$ $1.html [L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment