Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.6k views
Welcome To Ask or Share your Answers For Others

1 Answer

Bit long ago, but I'll answer the question anyway for those who come here by Google (like me). The answer is really simple:

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

R=301 means you do it via a 301 redirect. You don't want that


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...