Skip to content

Instantly share code, notes, and snippets.

@thicolares
Last active November 23, 2015 13:16
Show Gist options
  • Save thicolares/c79caa1ef7e0e084fbf9 to your computer and use it in GitHub Desktop.
Save thicolares/c79caa1ef7e0e084fbf9 to your computer and use it in GitHub Desktop.
Usando a HTML5 History Api no Angulajs (testado na versão 1.4.7)
Options +FollowSymLinks
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule (.*) index.html [L]
</ifModule>
angular.module('minhaApp', [])
.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
//...
// usando a HTML5 History API
// https://docs.angularjs.org/guide/$location
// nem todo navegador reconhece isso, mas a grande maioria: http://caniuse.com/#feat=history
$locationProvider.html5Mode(true);
//...
}])
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Language" content="pt-br">
<!--colocar a tag base-->
<base href="/">
<!--...-->
<a href="/a-route-name" title="A fancy title">
$location.path('/a-route-name');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment