我在我的角度应用程序中使用路由来加载网址。这工作完全当我点击来自应用程序内的链接,但是当我尝试直接到一个应用程序的URL,服务器返回404使用WordPress的角度HTML5模式,刷新页面导致404
这里是我的代码:
myApp.config(function ($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider
.when('/booking', {
templateUrl: 'wp-content/themes/myapp/pages/begin.html',
controller: 'mainController'
})
.otherwise({
redirectTo: "/"
});
});
我的头有<base href="/myapp/">
在顶部,在头部标签内。
我已阅读,这是一个Apache重写的问题,所以我想修改我的.htaccess包括以下内容:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /myapp/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /myapp/index.php [L]
</IfModule>
然而,这似乎并没有发挥作用以外重定向到404页。我正在使用WAMP和localhost。
如何使它刷新应用程序或直接链接到页面将工作?
服务器必须发送到客户端的index.html(或PHP)到underneith网址,(不定向),除非数据文件是存在的。 – YOU
一些类似的帖子 - http://stackoverflow.com/questions/28224012/angular-js-routes-not-working-on-wamp – YOU