Reputation: 254
In SennaJS and EmberJS both using History API. How those libraries avoid 404 when a URL is pasted in address bar.
Upvotes: 0
Views: 502
Reputation: 13439
You have to modify your webserver and enable mod_rewrite. Then the server will take the request and forward it to your index file, and ember and SennaJS will parse the URL as you would expect.
For Apache you need to enable mod rewrite and edit your vhost:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
and nginx:
rewrite ^(.+)$ /index.html last;
see: http://readystate4.com/2012/05/17/nginx-and-apache-rewrite-to-support-html5-pushstate/
Upvotes: 1