Django:如何重定向到外部URL?

Django:如何重定向到外部URL?,django,http,url,redirect,http-headers,Django,Http,Url,Redirect,Http Headers,[Django 1.0.2] 我的视图设置如下: (r'^redirect/(?P<object_id>\d+)/(?P<url>.*)/$', 'django.views.generic.simple.redirect_to', {'content_type': SiteType}, 'clickout'), 我检查了HTTP头,它确实尝试了错误的URL: """HTTP/1.x 301 MOVED PERMANENTLY Date: Thu, 26

[Django 1.0.2]

我的视图设置如下:

(r'^redirect/(?P<object_id>\d+)/(?P<url>.*)/$',
    'django.views.generic.simple.redirect_to',
    {'content_type': SiteType}, 'clickout'),
我检查了HTTP头,它确实尝试了错误的URL:

"""HTTP/1.x 301 MOVED PERMANENTLY

Date: Thu, 26 Feb 2009 06:58:35 GMT

Server: Apache/2.0.52 (Red Hat) mod_wsgi/2.0 Python/2.5

Etag: "d41d8cd98f00b204e9800998ecf8427e"

Location: http://mydomain.com/example.com
Content-Type: text/html; charset=utf-8

Vary: User-Agent,Accept-Encoding

Content-Encoding: gzip

Content-Length: 20
“”“

可能有什么问题?如何重定向到外部URL

编辑 在URL中嵌入URL似乎不是一个好主意。apache和mod_wsgi都在折叠双斜杠。()

但将目标URL作为参数使用效果很好:

"/redirect/2/?url=http://www.example.com/"

非常感谢支持部门的Sean F对我的帮助。

你是如何运行mod_wsgi服务器的?我希望,因为你直接通过Django运行本地服务器,所以不会发生url重写。在远程服务器上,url会被重写,以便在传递到Django应用程序之前删除双斜杠。

它会加载mod_rewrite,但似乎没有任何重写的配置。我在Web派系上运行,它是一个单独的apache实例。这与此有关吗?“WSGIScriptAlias//path/to/my/project/myproject.wsgi”
"/redirect/2/?url=http://www.example.com/"