When I access
http://my_site.com/api/my_project/submitSearch.php?skills=C+OR+%28C%2B%2B+AND+UML%29
I get an HTTP response of 403.
The point being that I am encoding skill=C OR (C++ AND UML)
in Python using urllib.parse.quote_plus()
.
If I use skill=(C++ AND UML)
, then there is no problem.
http://my_site.com/api/my_project/submitSearch.php?skills=%28C%2B%2B+AND+UML%29
I can only assume that the URL is triggering some Apache config rule. I asked my ISP and their solution was to allow all access from my current IP address. BUT, I want to allow everyone to access this URL, so how can I configure my Apache to allow this?
OR, am I wrongly encoding my URL in Python? Strangely, when I use encodeURIComponent()
in JavaScript, the server does not reject the request.
So, the JS/Python encodings are
Python: http://localhost/api/enigma/submitSearch.php?skills=C+OR+%28C%2B%2B+AND+UML%29
JS: http://localhost/api/enigma/submitSearch.php?skills=C%20OR%20(C%2B%2B%20AND%20UML)
Also, the problem is only at my ISP, not on localhost
2
Answers
I’m not familiar with Apache, so I can’t help you there.
To get the same output as JavaScript’s
encodeURIComponent
, try usingurllib.parse.urlencode
withurllib.parse.quote
(instead ofquote_plus
).skills=C%20OR%20(C%2B%2B%20AND%20UML)
You could try adding an
.htaccess
file to the directory (or even root directory of your website) containing the content in your Apache server in the relevant directory. This should grant access to anyone that tries to access the dir.You can even wrap these directives like so:
to make it apply to a given dir.