I am using Angular Ui-Router in my web app. Right now I have to use example.com/#/
to access this. How do I redirect users from example.com
to example.com/#/
in Nginx?
Asked
Active
Viewed 56 times
0

Patrick Mevzek
- 10,995
- 16
- 38
- 54

apacc
- 1
- 2
-
The solution is to use two server block in your nginx config file [like this][1] [1]: http://stackoverflow.com/questions/10294481/how-to-redirect-a-url-in-nginx – aitnasser Dec 31 '15 at 22:08
1 Answers
0
I think that should be purely client-side.
Your webserver will serve the user index.html
which bootstraps the Angular application.
In your application, you'll have to configure a redirect from "" and "/" to your desired route.
This example below will redirect the user from example.com
to example.com/#/home
.
angular
.module('home', ['ui.router'])
.config(function ($stateProvider, $urlRouterProvider) {
$urlRouterProvider.when('', '/home');
$urlRouterProvider.when('/', '/home');
});

Patrick Mevzek
- 10,995
- 16
- 38
- 54

Henry Zou
- 1,809
- 1
- 14
- 19