.htaccess 重定向到外部 URL,同时隐藏重定向 [英] .htaccess redirect to external URL while hiding redirect

查看:38
本文介绍了.htaccess 重定向到外部 URL,同时隐藏重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够将指向我的虚拟主机的域重定向到外部域.

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

例如,我的 .htaccess 中有这个:

For example, I have this in my .htaccess:

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

但是,当我访问域时,地址栏中的 URL 更改为 http://myexternal.example/site.

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

如何在不更改 URL 的情况下重定向?

How can I redirect without changing the URL?

还有其他方法可以解决这个问题吗?我需要使用框架/iframe吗?

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

推荐答案

很久以前,但无论如何我都会为那些通过 Google 来到这里的人(像我一样)回答这个问题.答案很简单:

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

在您的 htaccess 中,删除 R=301 部分(当然还有逗号).

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

R=301 表示您通过 301 重定向来完成.你不想那样

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

这篇关于.htaccess 重定向到外部 URL,同时隐藏重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆