javascript - Angularjs routing throws 404 without # -
i creating website angularjs , using ngroute module handle page requests.
in app.config
function have setup routing follows:
app.config(function($routeprovider, $locationprovider, $httpprovider){ $locationprovider.html5mode(true); $routeprovider.when('/', { templateurl: 'pages/index.html', controller: 'maincontroller' }).when('/testpage', { templateurl: 'pages/test.html', controller: 'testcontroller' }).otherwise({ redirectto: '/' }); });
when try access test page, on mamp local server, adding #
before page name this: http://dev.mysite.com:8888/#testpage
works fine.
however, if don't add #
before page name, this: http://dev.mysite.com:8888/testpage
404 error.
i have added <base href="/">
<head>
of index.html page contains <div ng-view>
tag.
i appreciate if explain doing wrong.
angular looks # symbol handle routing. after # symbol interpreted routing function. no # symbol, no angular route. if can run in html5 mode, can turn off, work older browsers, needed.
Comments
Post a Comment