I've been asked to create a 307 redirect for a domain, ensuring it is "masked". i.e. keep the original URL in the address bar.

There isn't a lot of info available about 307 (as opposed to 301/302) redirects, but from my investigations it seems that 307 redirects are similar to 302 redirects.

I have a feeling what I've been asked to do is impossible, and for now I have created an iframe which loads up his free-hosted-website.

Before I look an idiot and go back to him, and tell him iFrames are the only way to retain the URL in the address bar, can someone confirm this.

Alternatively, tell me how to create a 307 redirect. I assume it's something like this.... But how can it be masked?

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=307,L] 
  • 2
    Why are you being asked for a 307 redirect? A 307 is a "yes I'm sure this is a redirect that is only temporary" type of redirect. As opposed to a 302 which is supposed to be temporary, but often used as the default redirect type. I'd only use 307 redirects for requests that you know will need to be done again and change. Something like redirecting to the login page. Mar 2, 2016 at 10:37
  • Could you use a cname record instead? Mar 3, 2016 at 0:33

2 Answers 2


A masked 307 redirect is not possible. You can either redirect or mask but not both together. The code you posted in your question will achieve the redirect if thats the solution you want, but I don't understand why you would want a 307 redirect, which just tells the browser it can't switch between GET/POST method. Best/common practice is to stick to 301 for permanent redirects and 302 for temporary redirects unless this might be used on a URL where POST data is expected. A 307 redirect will not in itself apply any masking - a redirect header whether 301, 302 or 307 will change the browser address.

While most website masking is setup and managed using hosting or domain name control panels rather than people writing source code for it themselves, the method used most today is still the old HTML4 frameset tags which all major browsers still support:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" 
  <frameset rows="100%">
    <frame src="http://www.masked-domain.com/" />

To mask by proxying requests you could use PHP code similar to this in index.php:

$sOldURL = sprintf( 'http://www.masked-domain.com/%s', $_SERVER['REQUEST_URI'] );
echo( @file_get_contents( $sOldURL ));

and then redirect all requests to that index.php file using a .htaccess file:

RewriteEngine On
RewriteRule ^(.*)$ /index.php/$1 [L]

It's impossible to externally redirect (3xx status) and mask the request (ie. keep the original URL in the address bar). To the end user, a "masked" URL just looks like an ordinary (200 OK) request. A 3xx response is not.

iFrames are the only way to retain the URL in the address bar

However, iframes are not necessarily the only way to mask the URL. Assuming this is a cross-domain request, then the request could be proxied?

...his free-hosted-website.

Well, in this case, an iframe might well be the only way to handle this!

Part of me thinks there must be something else to this? Where are you wanting to "redirect" from?

  • There's not much more really. We designed and used to host his site for him, but now he's had someone to create a "wix" site for him. So redirecting from a completely empty site on our servers (barring the iframed index.html file)
    – Rob
    Mar 2, 2016 at 11:16
  • So, he's changed domain name? ...His old domain is still pointing at your server and he's got a new domain (or a free Wix subdomain?) on his new Wix site?
    – MrWhite
    Mar 2, 2016 at 11:21
  • A free wix subdomain with like this.. mysites.wix.com/mynewsite He wants to keep his existing domain name, and not show his users the URL mysites.wix.com/mynewsite
    – Rob
    Mar 2, 2016 at 11:24
  • 1
    If he wants to keep his existing domain then he'll need to upgrade to a premium plan (not free) and connect the domain to their Wix site. (They will also need to 301 redirect their old URLs to the new Wix URLs - assuming they are different - this is also a premium feature.) ... Or use an iframe, but that has a number of huge disadvantages, as I'm sure you are aware.
    – MrWhite
    Mar 2, 2016 at 11:34
  • Thanks for your answer. w3dk. I marked richhallstoke answer as correct as, although both were great answers, his was a little more complete. But again, thanks.
    – Rob
    Mar 8, 2016 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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