views:

467

answers:

3

I want to be able to redirect a domain pointed to my webhosting to an external domain.

For example, I have this in my .htaccess:

RewriteCond %{HTTP:Host} ^(?:www\.)?mydomain\.example$ 
RewriteRule ^(.*)$ http://myexternal.example/site [R=301,NC]

However, when I visit the domain, the URL in my address bar changes to http://myexternal.example/site.

How can I redirect without changing the URL?

Is there another way around this? Do I need to use a frame/iframe?

+2  A: 

Either a single frame frameset, or an iframe with width/height set to 100%.

I'm not sure if framsets are supported in newer versions of HTML, but browsers still understand old versions anyway... but a single iframe is easy anyway.

<html>
<head>
<title>My Site</title>
<style>
body {
    margin: 0;
    padding: 0;
}
body, iframe {
    width: 100%;
    height: 100%;
}
iframe {
    border: 0;
}
</style>
</head>

<body>
<iframe src="http://example.com" />
</body>
</html>
Matthew Scharley
Not new browsers, new versions of HTML. ie, I'm pretty sure there's no framset DTD for any version of XHTML.
Matthew Scharley
Frameset is supported by newer browsers.Fameset support info: http://reference.sitepoint.com/html/frameset
Richard
You can see which DTD to use here: http://reference.sitepoint.com/html/elements-and-dtdsThere is a special XHTML for framesets: "XHTML 1.0 Frameset"
Richard
Gah, and here I thought people might have moved on from frames...
Matthew Scharley
A: 

Maybe you can achieve this by changing the DNS for your domain mydomain.net to link to myexternal.net. Then, you have to use an appropriate .htaccess on your external server.

Martin