0

I'm using AngularJS and Apache. For routing I'm using ui router module.

I have a site http://example.com I have a rule in .htaccess => DirectoryIndex index.html

So when user goes to http://example.com it renders index.html but not shows it on URL

On Index.html there is a button which you click and send you to userwelcome page

This is the url => http://example.com/userwelcome.html#/welcome

The userwelcome page has 3 states. Login, Signup and Welcome

The code from userwelcome.js

.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {

                $urlRouterProvider.otherwise('/welcome');
                $stateProvider
                        .state('login', {
                            url: '/login',
                            templateUrl: 'login/vw_login.html',
                        })
                        .state('welcome', {
                            url: '/welcome',
                            templateUrl: 'userWelcome/vw_welcome.html',
                        })
                        .state('signup', {
                            url: '/signup',
                            templateUrl: 'signup/vw_signup.html'
                        });

            }]);    

When the user logins, the site redirects to home.html page and the URL is => http://example.com/home.html#/home

What I want is that URLs like the following:

for userWelcome.html welcome state http://example.com/welcome

for userWelcome.html login state http://example.com/login

for home.html home state http://example.com/home

With this structure is possible? or I have to have all states (login, signup, home, userwelcome) in one single page?

With ngroute I read that you can use html5mode with $location. In my case I m using ui router, so can I mix both of them?

In Apache I have to create more rules for rewrite?

I find a lot of post, articles talking about pretty URLs but each one has different solutions and I can't make it work.

1 Answer 1

0

Since angularjs target SPA every thing actually run from one page and it # sign trigger routing (ui-route) to load view associated with it and using # will prevent browser from go to another page.

so you can not run your site to URL like example.com/user then example.com/home because it is different navigation URL for the browser

Sign up to request clarification or add additional context in comments.

3 Comments

but when you see apps like twitter, facebook, about me, and others that they have urls like app.com/username , I dont think they use only a single page pattern, and have all views on index.html
I thought you develop a SPA using angularJS, and I think facebook and twitter not a SPA
I m using Angular. At first, twitter was SPA [link] (quora.com/…)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.