app-router examples
April 23, 2015 ยท View on GitHub
Example app-router setup to get you running locally.
Download and un-zip the examples.
hash-routing
Hash routing uses hash paths /#/paths.
- Open a terminal in the
hash-routingdirectory - Start a static content server with node
http-serverorpython -m SimpleHTTPServer 8080 - Open http://localhost:8080/
pushstate-routing
Push state routing uses regular paths /path and extends <a> tags with the pushstate-anchor.
<a is="pushstate-anchor" href="/home">Home</a>
- Open a terminal in the
pushstate-routingdirectory - Start the express.js server with
node server.js - Open http://localhost:8080/
Other Routers
Examples of app-router, flatiron-director, and plain old HTML files.
https://github.com/erikringsmuth/polymer-router-demos
HTTP Server Pushstate Configurations
Examples of HTTP Server configurations to get pushstate working.
Apache .htaccess
Options +FollowSymLinks
IndexIgnore /
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.html
Nginx Conf - to be inserted in your server{} declaration
location / {
try_files $uri @rewrites /index.html;
}
# If no asset matches, send it to your javascript app. Hopefully it's a route in the app!
location @rewrites {
rewrite .* /index.html last;
}