Skip to content

Instantly share code, notes, and snippets.

@takahiro-saeki
Forked from pablodgonzalez/spa-htaccess
Created June 26, 2016 16:29
Show Gist options
  • Save takahiro-saeki/b337488f396516ec9ef0785952d3e882 to your computer and use it in GitHub Desktop.
Save takahiro-saeki/b337488f396516ec9ef0785952d3e882 to your computer and use it in GitHub Desktop.
spa tips
RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Redirect http://www. to just http://
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=
RewriteCond %{HTTP_HOST} ^touchtyping.guru [NC]
RewriteRule ^ snapshots%{REQUEST_URI}-en.html [L]
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=
RewriteCond %{HTTP_HOST} ^(es|pl|en).touchtyping.guru [NC]
RewriteRule ^ snapshots%{REQUEST_URI}-%1.html [L]
# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [QSA,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment