Skip to content

Instantly share code, notes, and snippets.

@ravgeetdhillon
Created June 25, 2020 09:23
Show Gist options
  • Save ravgeetdhillon/ccd75c4d0e675afffdb8988a5a0a6a3b to your computer and use it in GitHub Desktop.
Save ravgeetdhillon/ccd75c4d0e675afffdb8988a5a0a6a3b to your computer and use it in GitHub Desktop.
htaccess redirection
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
RewriteRule ^index\.html$ https://example.com/ [R=301,L]
<FilesMatch ".(jpg|jpeg|png|gif|ico|svg)$">
Header set Cache-Control "max-age=7776000, public"
</FilesMatch>
<FilesMatch ".(css|js)$">
Header set Cache-Control "max-age=7776000, public"
</FilesMatch>
Options All -Indexes
<FilesMatch "\.(ttf|otf|eot|woff|woff2)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
Header set Cache-Control "max-age=31536000, public"
</IfModule>
</FilesMatch>
<Files .htaccess>
order allow,deny
deny from all
</Files>
ErrorDocument 404 /404.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment