Category Archives: angularjs-ui-router

AngularJS + UI Router state url and htaccess rule issue

I am creating a project in angularjs with ui-router

I have an abstract state with URL '/' and many child for that. For eg:

$stateProvider
    .state('main', {
        url: '/',
        abstract: true,
        templateUrl: 'templates/main.html'
    })
    .state('main.one', {
        url: 'one',
        templateUrl: 'templates/one.html'
    })
    .state('main.two', {
        url: 'two',
        templateUrl: 'templates/two.html'
    });


 $urlRouterProvider.otherwise('one');

So I can access main.one state /one and main.two /two

It's everything working fine.

Now the issue is, i am planning to create some htaccess rule for crawler

So, I have these rules

RewriteCond %{QUERY_STRING} ^_escaped_fragment_=(.*)$
RewriteRule .* /snapshots/index.php?page=$1 [L]

But whenever url coming like /?_escaped_fragment_= it's taking me main state. htaccess is not working because I assigned / as URL for main state.

Anyone have idea?

UPDATE

This htaccess is working fine in my local, windows 10 with WampServer Version 2.5

And production server is ubuntu server with apache2

Also if I remove RewriteCond %{QUERY_STRING} ^_escaped_fragment_=(.*)$ this line it's working in apache2