I have a url with a pattern like so:
('^(?i)somewhere/(\d+)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/$', somewherePage),
where it should pick up a URL like:
http://foo.com/somewhere/1337/foo/params/that/are//maybe///used/
Notice how some of the parameters are not present and result in //. This has stopped working and instead of the correct url I am getting something like:
http://foo.com/somewhere/1337/foo/params/that/are/maybe/used/
where the needed slashes are not there and my pattern is then not recognized. I think this may be caused by something my apache web server is doing but I am not how to figure this out.
My question is how can I stop the extra slashes from being removed or is there another solution for having a dynamic number of parameters. Also this code used to work fine but has sense stopped. I am unsure what has changed as the code base is legacy but I know this way of passing a variable number of parameters has worked.
is there another solution for having a dynamic number of parameters
Yes, it's called a query string. Instead of that ugly pattern use a simpler one (one that matches required parameters), and pass everything else after ?
, e.g. example.com/foo/42?p1=foo&p2=bar
.
You can then extract them from request.GET
.
I've ran into this question after debugging a similar issue on Django. The extra slash was always dropped due to nginx. Adding a merge_slashes off
in nginx configuration fixed the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With