.htaccess redirects to an external URL, hiding redirection.

I want to be able to redirect the domain pointed to by my web hosting 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? Do I need to use a frame / iframe?

+5
source share
5 answers

A bit a long time ago, but I still answer the question of who will come here Google (like me). The answer is very simple:

In htaccess, remove the R = 301 part (and, of course, the comma).

R = 301 , 301 . ,

+8

, iframe /, 100%.

, HTML, ... iframe .

<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>
+2

, , DNS mydomain.net myexternal.net. .htaccess .

+1

. , op, - mod-proxy. domainA domainB, P mod-rewrite.

RewriteRule ^(.*)$ http://domainB.com/$1 [P]

.

, mod-proxy.

0

, URL, .

1: URL. URL-, . , DomainB.com, , DomainA.com, , , , -. , .htaccess , , : RewriteCond% {HTTP_HOST} ^ DomainA.com RewriteRule ^ (.) Http://DomainB.com/ $ 1 [P] cPanel, , . ? .htaccess DomainA.com/YourPage, DomainB.com/YourPage*

2. URL. URL-, . , DomainA.com , :

RewriteCond% {HTTP_HOST} ^ DomainA.com RewriteRule ^ (.) Http://DomainB.com/PathToPageHere [P] *

* , , , , , blogspot.com , , etsy.com, , . , URL-. 3. IP-. IP- URL-. , .htaccess.

IP- ( ## IP-) http://domain_name.com

RewriteCond% {HTTP_HOST} ^ ##. ##. ##. ## RewriteRule (.) Http://domain_name.com/ $ 1 [R = 301, L]

0
source

All Articles