Skip to content

Instantly share code, notes, and snippets.

@jordansaints
Last active August 29, 2015 14:23
Show Gist options
  • Save jordansaints/b16919de70338650765e to your computer and use it in GitHub Desktop.
Save jordansaints/b16919de70338650765e to your computer and use it in GitHub Desktop.
#
# Apache directives for serving a javascript application.
# Requests that don't match a file or directory are served
# the index.html file so that your javascript router may load
# and handle the requested route.
# by Jordan Saints, www.jordansaints.com
#
# Optional, easier than sudo copying your app to your DocumentRoot.
Alias /app /path/to/your/app
<Directory "/path/to/your/app">
AllowOverride None
Options Indexes FollowSymLinks
Require all granted
RewriteEngine On
RewriteBase /
# rewrite is conditional on request not being a file (-f) or a dir (-d)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /app/index.html [L,QSA,NC,NE]
# NC - ignore case comparison
# NE - do not encode RHS URI
# QSA - append exisiting query string into new one
# L - mark as last rule
</Directory>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment