【发布时间】:2017-10-11 23:28:28
【问题描述】:
让 Django 在 https 端口 (443) 上运行。当用户访问https://hostname/newAPP时,我希望Django重定向到https://hostname:port。
我在 urls.py 的 urlpatterns 中尝试了以下行,但无法得到结果。
url(r'^newAPP$', RedirectView.as_view(url=':8000', permanent=True), name='NewApp')
实际上它正在被重定向,但是到了一个格式错误的 url “https:hostname/:8000”。请注意,“:”放在“/”之后。
服务器有多个 IP/主机名,因此无法对 IP/主机名进行硬编码。
【问题讨论】: