0

I have to redirect the request that a Apache web server receives, using the user_agent to filter. The idea is that if the user_agent is "Mozilla/5.0 (Macintosh; Intel Mac OS X 12_2_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15" then the proxy have to redirect the request to a machine with ip 192.168.1.40 but if the user agent is not that it have to show the main page.

I have the next code to redirect to the correct machine:

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} "=Mozilla/5.0 (Macintosh; Intel Mac OS X 12_2_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
RewriteRule ^/(.*)$ http://192.168.1.40:443/$1 [L,R=302]

But I have a problem. When I redirect to 192.168.1.40 I need to also add the query string so if the request is http://192.168.2.11/thisisthequery then I need to redirect it to http://192.168.1.40/thisisthequery not just http://192.168.1.40

I've tried the next

 RewriteRule ^/(.*)$ http://192.168.1.40:443/%{QUERY_STRING}$1 [L,R=302]

But it doesn't work, how can I do that??

IMPORTANT

The query doesn't exist in the proxy so if I request http://192.168.2.11/thisisthequery I think it isn't even trying to redirect because the response is a Bad request (443). So, how can I redirect before the proxy return the 443 message??

1
  • it is unclear to me what you want to Archiv. however if you just want to catch the resource from a other destination, a reverse proxy could make this for you
    – djdomi
    May 17 at 17:51

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.