Mobile app version of vmapp.org
Login or Join
Cugini213

: Is a masked 307 redirect for a domain possible? 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

@Cugini213

Posted in: #302Redirect #Domains #Htaccess #Redirects

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 (.*) www.newdomain.com/ [R=307,L]

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Cugini213

2 Comments

Sorted by latest first Latest Oldest Best

 

@Martha676

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"
"http://www.w3.org/TR/html4/frameset.dtd">
<html>
<frameset rows="100%">
<frame src="http://www.masked-domain.com/" />
</frameset>
</html>


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

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


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

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

10% popularity Vote Up Vote Down


 

@Ogunnowo487

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?

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme