Skip to content

Instantly share code, notes, and snippets.

@joshdcomp
Created March 9, 2016 16:36
Show Gist options
  • Save joshdcomp/3683a9e127b4c259d3a1 to your computer and use it in GitHub Desktop.
Save joshdcomp/3683a9e127b4c259d3a1 to your computer and use it in GitHub Desktop.
.htaccess for one-page web apps: redirect everything except requests for filenames ending in `.png, .jpg, .gif, .jpeg, .bmp, .js, .css, or .svg` (you can add more to that list where you see those file endings)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.png|\.jpg|\.gif|\.jpeg|\.bmp|\.js|\.css|\.svg)$
RewriteRule ^(.*) /index.html [L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment