I am currently trying to use mod_proxy to make search requests on another server. The remote server requests must be structured as follows:
http://path.to.remote/search.php?key=MYKEY&term=SEARCHTERM
In an effort to obfuscate my access key, I was hoping to contain the authentication within my vhost definitions. Since the key must be passed as a query string value, I thought it would be as simple as:
ProxyPass /lookup/t/ http://path.to.remote/search.php?key=MYKEY&term=
Where my URLs would look like
http://localhost/lookup/t/term=SEARCHTERM
I quickly discovered that ProxyPass preforms mandatory character escapes on the target URL which rendered my URL unusable. I found lots of people who had similar issues, primarily with previously encoded characters, and that URL encoding with ProxyPass was unavoidable.
I found a few suggestions that I should use mod_rewrite to assemble the proxy request for me, but I wasn't sure how to do so. I ended up with rules in my vhost definition that look something like:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/lookup/t/
RewriteRule ^/lookup/t/$ http://path.to.remote/search.php?key=MYKEY&term=$1
I don't have a lot of experience with mod_rewrite, and my regex skills aren't great, so I'm hoping someone can explain how I would rewrite my URL and how to funnel it through mod_proxy as needed. Am I correct in thinking I need to use rewrite to assemble the query string like so:
Http://localhost/lookup/t/term=SEARCHTERM
Http://localhost/lookup/t/?key=MYKEY&term=SEARCHTERM
and then use mod proxy to go from
/lookup/t/
to
http://path.to.remote/search.php