Backbone.js and mod rewrite

So, I play with the spine and got to where the direct pages that use pushState load are not working properly. if I try to go to my.url.com/login, it will give me the page not found, which it should, because this does not directly exist. I have the following rewrite rule:

RewriteEngine On RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d RewriteRule (.*) index.html [L,QSA] 

hoever this doesn't seem to work (thought with him I get a bad request, not found). How can I get the pushState url to load correctly using mod rewrite?

+8
javascript apache pushstate mod-rewrite
source share
1 answer

This is actually the first thing I read in the new API of the story and how Backbone works - pretty cool stuff.

To solve the bad query problem, all you have to do is add / before index.html . For my part, that redirects correctly internally and passes the query string, as you would expect.

 RewriteEngine On RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d RewriteRule (.*) /index.html [L,QSA] 
0
source share

All Articles