angularJS how to user accessible url routing? -


the basic routing method below,

angular.module('myapp', ['myapp.filters', 'myapp.services', 'myapp.directives', 'myapp.controllers']).  config(['$routeprovider', '$locationprovider', function($routeprovider, $locationprovider) {   $routeprovider.when('/view1', {templateurl: 'partials/partial1.html', controller: 'myctrl1'});   $routeprovider.when('/view2', {templateurl: 'partials/partial2.html', controller: 'myctrl2'});   $routeprovider.otherwise({redirectto: '/view1'});   $locationprovider.html5mode(true); }]); 

i want make user can access view1 typing url "://host/view1" on browser. not work..

by using $routeprovider , $locationprovider, if user click "href=/view1" link, page routed host/view1.

but if user access directly url "://host/view1" emit 404 error. make user can access /view1 directly url, have remove html5mode then, user can access "://host/#/view1"

but how can remove # symbol!? not html5mode, method user can access page directly typing url.

thanks. yoshi

i create .htaccess file on documentroot folder , add below

rewriteengine   on rewritebase     / rewritecond     %{request_uri} !^(/index\.php|/img|/js|/css|/robots\.txt|/favicon\.ico) rewritecond     %{request_filename} !-f rewritecond     %{request_filename} !-d rewriterule     .               /index.html              [l] 

into .htaccess file.

that works expected!

ps.

rewritecond     %{request_filename} !-f rewritecond     %{request_filename} !-d 

above 2 lines means if file specified name in browser doesn't exist, or directory in browser doesn't exist procede rewrite rule below


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -