2016-08-23 24 views
0

我的spa實際上只是一個使用自定義模板的正常wordpress頁面。在WordPress內部的Angular SPA中使用html5Mode - ngRoute返回一個404

頁嵌條/ singlepageapp /所以我的基礎:是<base href="/singlepageapp/">

使用$ routeProvider我可以在我的觀點點擊沒有問題,但如果我嘗試打網址冷http://mysite/singlepageapp/singleview我得到一個404由於WordPress的不通過spa頁面路由這些頁面。

我是否需要特殊的htaccess重寫規則或我怎麼能得到相當的URL在我的水療中心頁面出404的

$routeProvider. 
when('/', { 
    templateUrl: '/wp-content/themes/mytheme/templates/map.html', 
    controller: 'VPListCtrl' 
}). 
when('/:slug', { 
    templateUrl: '/wp-content/themes/mytheme/templates/detail.html', 
    controller: 'VPDetailCtrl' 
}). 
otherwise({ 
    redirectTo: '/' 
}); 

$locationProvider.html5Mode(true); 

回答

0

我想我有一個WordPress的重寫工作解決方案規則

function custom_rewrite_to_spa() { 
$singlepageapp_page_id = 11730; 
add_rewrite_rule('^singlepageapp\/(.*)\/?', "index.php?page_id={$singlepageapp_page_id}", 'top'); 
} 

add_action('init', 'custom_rewrite_to_spa');