1

Working on a BackBone app that has this mod_rewrite in place to handle routing all traffic through index.html that isn't targeting a file:

modRewrite(['^[^\\.]*$ /index.html [L]'])

It's working beautifully, but now I need to update it so that it ignores that root-level api directory. My API calls look like this:

http://localhost:9000/api/customers/

They're all breaking because it's trying to route them through index.html. FYI, I'm using Grunt connect-modrewrite locally to manage issues with routing and localhost.

1 Answer 1

1

You can try negative lookahead based regex:

modRewrite(['^(?!/?api)[^\\.]*$ /index.html [L]'])
2
  • Would this also ignore anything that comes after /api? Aug 17, 2014 at 20:01
  • Yes it will ignore anything that comes after /api/ also.
    – anubhava
    Aug 18, 2014 at 1:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.