Apache Django URL problem
I allow users to submit a query at mysite.com/go/QUERY\
If the query contains "/" Apache chokes.
From urls.py:
(r'^go/(?P<querytext>.*)$', 'mysite.engine.views.go'),
Try:
http://mysite.com/go/http%3A%2F%2F
Result:
Not Found
The requested URL /go/http:// w开发者_如何学运维as not found on this server.
Apache/2.2.12 (Ubuntu) Server at ...
BUT, if I enter the non URL quoted values it works:
http://mysite.com/go/http://
WORKS just fine...
Any ideas?
Your httpd is blocking encoded slashes.
try adding AllowEncodedSlashes On
to your apache config to enable encoded slashes in apache (docs)
From the Django docs it looks like you're only supposed to use the (?P....)
notation when implementing a named group (http://docs.djangoproject.com/en/1.1/topics/http/urls/#named-groups).
Try fixing your regex by either getting rid of the ?P
or completing the syntax and naming the group like (?P<search-term>.*)
Looks like you might need to decode the URL before you pass it along. You can do this with urllib.unquote
.
>>> import urllib
>>> urllib.unquote("""http%3A%2F%2F""")
'http://'
精彩评论