3

I need help regarding AngularJs application. I need htacess file for HTML5Mode in AngularJS and Hashbang fallback. Can someone help me? Cuz i get %2F when i use backslash. I've been folowing along this tutorial but they use express. https://scotch.io/tutorials/angularjs-seo-with-prerender-io

HTML

<html lang="en" ng-app="WebApp">
<head>
    <meta charset="UTF-8">
    <base href="http://localhost/myapp/">
    <meta name="fragment" content="!" />
</head>

and this is my mainjs

var app = angular.module('WebApp', ['ngRoute']) 

app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider){ 

  $routeProvider.when('/', { 
    templateUrl : 'views/home.html', 
    controller: 'PageCtrl' 
  })

  $routeProvider.when('/about', {
      templateUrl : '/views/about.html',
      controller: 'PageCtrl'
  })


  $routeProvider.otherwise({
          redirectTo : '/'
  });

  $locationProvider.html5Mode(true);
  $locationProvider.hashPrefix('!');
}]);



function PageCtrl($scope) { 
  // For this tutorial, we will simply access the $scope.seo variable from the main controller and fill it with content. 
  // Additionally you can create a service to update the SEO variables - but that's for another tutorial. 

}

and this is me trying to get htacess right

RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^  index.html#! [L]
8
  • Please don't post cross site duplicates: stackoverflow.com/q/33591367/1190388
    – hjpotter92
    Nov 8, 2015 at 8:43
  • This is the exact same problem that I am facing on localhost Apache. Even if I get the navigation to work, it breaks on page reload. Not sure what will fix this. Any help is highly appreciated.
    – Devner
    Jan 13, 2016 at 6:18
  • @hjpotter92 It seems like the link that you posted is broken. Can you please post the relevant link? This problem has been bugging me for a lot of time. Any help is appreciated. Thank you.
    – Devner
    Jan 13, 2016 at 6:19
  • @Devner The link is correct, but the question has been deleted: " deleted by Community♦ Dec 12 '15 at 9:26 (RemoveDeadQuestions) This question was automatically deleted."
    – hjpotter92
    Jan 13, 2016 at 6:24
  • @hjpotter92 Thanks for the prompt reply. By any chance, do you happen to know of any working solution? I have tried out the solutions provided on other threads but they all seem to be obsolete and do not work with angular version 1.4.7 (this is what I am using).
    – Devner
    Jan 13, 2016 at 7:15

1 Answer 1

-1

The problem is apache and encoded slashes. / is eacaped as %2f its code for slash. Allow encoded slashes on in your vhost file should solvle the problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .