javascript - Redirect to main page when comming from outside url angularJS -
i have angularjs
routing:
angular.module('diam8app', ['ngroute']) .config(['$routeprovider','$locationprovider', function($routeprovider,$locationprovider) { $routeprovider. when('/', { templateurl: 'main.html' }). when('/calculator/', { templateurl: 'calculator.html', controller: 'calculatorctrl' }). when('/contact/', { templateurl: 'contact.html', controller: 'contactctrl' }). otherwise({ redirectto: '/' }); $locationprovider.html5mode(true); }])
everything works fine, when i'm trying subpage directly url, example mydomain.com/contact
, i'm recieving http 502
. think routing doesn't work, when accessing outside.
so question is: there way redirect user main page, when comes different page (routing main must work works now)? perhaps .htaccess
or other angular configuration needed?
everything afther hash isn't taken in consideration server , angularjs handle that.
if use html5 mode, '#' prefix deleted.
the '#' deleted because of seo, can handled '!' prefix: $locationprovider.hashprefix('!');
when using html5mode, need take care of routes in backend!
Comments
Post a Comment