的URL我配置我的$ routeProvider這樣的:
angular.module('autotestApp').config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider){
$locationProvider.html5Mode(true);
$routeProvider
.when('/store', {
templateUrl: 'store.html',
controller: 'StoreController'
})
.when('/groups', {
templateUrl: 'groups.html',
controller: 'GroupsController'
})
.when('/purchases', {
templateUrl: 'purchases.html',
controller: 'PurchaseController'
})
.when('/settings', {
templateUrl: 'settings.html',
controller: 'SettingsController'
})
.otherwise({redirectTo: '/store'});
}]);
,我有以下幾個環節:
<ul>
<li><a href="store">Stores</a></li>
<li><a href="groups">Groups</a></li>
<li><a href="purchases">Purchases</a></li>
<li><a href="settings">Settings</a></li>
</ul>
當我點擊這些鏈接,它工作正常,但當我手動輸入瀏覽器或當我刷新頁面,我得到「頁面未找到」錯誤
UPDATE:
這是我的urls.py:
urlpatterns = patterns(
'',
url(r'^login', login_user, name='login'),
url(r'^logout', logout_user, name='logout'),
url(r'^register', register_user, name='register'),
url(r'^settings', user_settings, name='settings'),
url(r'^reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$',
reset_confirm, name='reset_confirm'),
url(r'^reset/$', reset, name='reset'),
url(r'^purchases', purchases, name='purchases'),
url(r'^_store', _store, name='_store'),
# payment
url(r'^payment/billing/(?P<vouchers_package_id>[0-9]+)$', billing_info,
name='billing'),
url(r'^payment/success', payment_success, name='payment_success'),
# vouchers
url(r'^vouchers/send_to_group/(?P<group_id>[0-9]+)',
send_vouchers_to_group, name='send_vouchers_to_group'),
url(r'^vouchers/send', send_voucher, name='send_voucher'),
# students in groups
url(r'^groups/students/delete/(?P<group_student_id>[0-9]+)',
delete_student, name='delete_student'),
url(r'^groups/students/(?P<student_id>[0-9]+)', students,
name='student_detail'),
url(r'^groups/students', students, name='students'),
# groups
url(r'^groups/delete/(?P<group_id>[0-9]+)', delete_group,
name='delete_group'),
url(r'^groups/(?P<group_id>[0-9]+)', groups, name='group_detail'),
url(r'^groups', groups, name='groups'),
url(r'^$', dashboard_page, name='dashboard'),
)
如何解決這一問題?
您必須在您的網絡服務器配置中設置重寫或使用#標記。在哪個網絡服務器上運行? – 2014-12-04 09:07:43
@RaphaelMüller我正在使用Django的服務器 – Rodrigue 2014-12-04 09:09:41
'.html5Mode(true);'需要一些服務器端設置。 – Jai 2014-12-04 09:11:13