Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 they get shown the content of a page on another domain 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$ [QSA,L]

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

share|improve this question
up vote 3 down vote accepted

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 ^(.*)$$1 [P]
share|improve this answer

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;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<html xmlns="" lang="EN">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<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="" 
 frameborder="0" marginheight="0" marginwidth="0" 
 width="100%" height="100%" scrolling="auto"></iframe>

use old fashion frameset

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "">
<head><title>My First Frame Page</title>
<frameset cols="100%">
<frame src="">
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.