Take the 2-minute tour ×

I have access to a folder on a web server in which I would like to put a .htaccess file to so that when a user visits www.somesite.com/myfolder/index.html they get shown the content of a page on another domain www.someothersite.com/blah/blah2/blah3/index.php?user=80338 which has a horribly long url, which I don't have access to that folder. However, I don't want the user to see this url in their browser, just for it to happen behind the scenes - I have tried reading some tutorials about the web and what I came up with is in the myfolder directory:

RewriteEngine On
RewriteRule ^index\.html$ http://www.someothersite.com/blah/blah2/blah3/index.php?user=80338 [QSA,L]

This seems to do the redirect, but I get the new url too, how can I stop this?

share|improve this question
add comment

2 Answers

Setting up ProxyPass works, but I recently discovered you can do something similar with rewriting. Using the [P] flag at the end of your RewriteRule will cause the rewrite to be handled by mod_proxy. Basic example would be something like:

RewriteRule ^(.*)$ http://www.example.com/$1 [P]
share|improve this answer
add comment

Any external 301 or 302 redirect to the other page is going to be shown as the current location in the browser URL address bar. To achieve the result you want you have to keep the current parent document as your local index.html. So you have a couple of options to do that. (probably not a complete list...)

wrap the request in a ProxyPass

(this is probably the most transparent to the end user, as they have no way to detect that the page is actually remotely hosted, but is slightly more ball-achey)

To hide the redirect from the client, you would need to Proxy the request in the httpd.conf file for your VirtualHost like so;

 <Location /index.html>

To enable the above directives, you are going to need to install and enable the mod_proxy_http apache2 module, which is system dependent (e.g. yum, apt, a2enable)

However, you are going to get some interesting URL mapping issues, which you would have to tackle on a case-by-case basis, so to get this to work transparently would take some effort.

For example it depends how the links in your remote document are specified relative, or fully-qualified. You can fix each link and URL using ProxypassReverse and Mod_substitute rules.

Alternative: Load the page into an iframe (or use old skool frame)

You can use an iframe, which would be shown as the browser URL address bar, and load the remote document into an iframe with something like this;

<html xmlns="http://www.w3.org/1999/xhtml" lang="EN">
<title>Full Page IFrame</title>
<style type="text/css">
html {overflow: auto;}
html, body, div, iframe {margin: 0px; padding: 0px; height: 100%; border: none;}
iframe {display: block; width: 100%; border: none; overflow-y: auto; overflow-x: hidden;}
<iframe id="tree" name="tree" src="http://www.someothersite.com/blah/blah2/blah3/index.php?user=80338" 

use old fashion frameset

<head><title>My First Frame Page</title>
<frameset cols="100%">
<frame src="http://www.page3.com">
share|improve this answer
actually the latter probably makes more sense, given that it would "Just work" without too much faffing. –  Tom H May 29 '12 at 11:05
add comment

Your Answer


