0

Apache server receives request in following format

http://192.168.110.65/?http%3A%2F%2Fdev.virtualearth.net

How do I have Apache generate a redirect to the query string using mod_rewrite

http%3A%2F%2Fdev.virtualearth.net

This is my mod_rewrite

<IfModule rewrite_module>
RewriteEngine On
ErrorLog "logs/rewrite.log"
LogLevel trace8
RewriteCond %{QUERY_STRING} http
RewriteRule "/" %{QUERY_STRING} [R,END,NE,QSD] 
</IfModule>

This is in the logs:

Cannot map GET /http%3A%2F%2Fdev.virtualearth.net%2FREST%2Fv1%2FImagery%2FMetadata%2FAerialWithLabels%3Fincl%3DImageryProviders%26key%3DArqI7N2ea0D8oysu209dksva2GSUXRIz1fJZigqHRuHNQMhGHvVZwxg76pSlwBFi%26jsonp%3DloadJsonp758595 HTTP/1.1 to file

auth phase 'translate' gave status 403: /http://dev.virtualearth.net/REST/v1/Imagery/Metadata/AerialWithLabels?incl=ImageryProviders&key=ArqI7N2ea0D8oysu209dksva2GSUXRIz1fJZigqHRuHNQMhGHvVZwxg76pSlwBFi&jsonp=loadJsonp758595

The problem is instead of redirecting to the url in query string, it prepends current host to the URL (http://xx.xx.xx.xx/URL) and redirect, hence I get a 403. I need to find a way such that in redirection current host is not prepended.

3
  • 1
    I'm sure that if you browsed the mod-rewrite you would find an answer or something that will help you out. In the meantime, what have you tried and what happened.
    – user9517
    Jul 8, 2016 at 12:19
  • @lain I have updated the post with mod_rewrite i am using and logs output.
    – Rama Arjun
    Jul 8, 2016 at 12:33
  • Unfortunately, if the URL in the query string is fully URL encoded like this then I don't think it's possible to do this with mod_rewrite alone. Also note that a script of this nature, allowing arbitrary target URLs, is open to abuse. See also my answer to this related question: serverfault.com/questions/793230/…
    – MrWhite
    Nov 19, 2016 at 0:05

1 Answer 1

0

You can do the same thing with Proxy Pass. Try below solution

Open the httpd.conf located in the \conf directory. Look for the following LoadModule directives and uncomment them by removing the # at the beginning of the line.

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

At the bottom of the httpd.conf add the following lines to enable the re-rounting.

ProxyPass /images http://localhost:8080/images
ProxyPassreverse / http://localhost:8080/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .