Htacess重写为AngularJs应用程序

我需要关于AngularJs应用程序的帮助。 在AngularJS和Hashbang后备中,我需要HTML5Mode的htacess文件。 有人能帮我吗? 因为我使用反斜杠时,我得到%2F。 我一直在沿着这个教程,但他们使用快递。 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> 

这是我的主人

 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. } 

这是我试图让htacess正确

 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] 

问题是apache和编码的斜杠。 /是以%2f作为斜杠的代码。 在你的虚拟主机文件中允许编码的斜杠应该解决这个问题。