【发布时间】:2014-04-23 12:15:54
【问题描述】:
我在 Heroku 上托管我的 Django 应用程序,并且我的域名已在 Network Solutions 注册。当我输入我的域名时,即 www.example.com,Heroku 显示:
"Not Found
The requested URL / was not found on this server."
然后,我必须导航到显示我的应用登录页面的模板 URL,www.example.com/shipment/。
如何让我的根域 www.example.com 自动重定向到 www.example.com/shipment/,或者将 /shipment/ 的 URL 更改为我的根域?
这是我的应用程序的 urls.py:
from django.conf.urls import patterns, url
from shipment import views
urlpatterns = patterns('',
url(r'^$', views.landing, name='landing'),
url(r'^create-subscription/$', views.createSubscription, name='createSubscription'), #
url(r'^(?P<subscription_duration>\d+)/create-account/$', views.createAccount, name='createAccount'),
url(r'^create-account/pay/$', views.pay, name='pay'),
url(r'^create-account/confirm/$', views.confirm, name='confirm'),
)
这是我项目的 urls.py:
from django.conf.urls import patterns, include, url
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'subscription.views.home', name='home'),
# url(r'^subscription/', include('subscription.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^shipment/', include('shipment.urls', namespace = "shipment")),
url(r'^admin/', include(admin.site.urls)),
)
【问题讨论】:
-
如果你把
url(r'^$', 'shipment.urls.landing', name='landing'),加到你的项目url 怎么办?