重定向到其他域,但保持类型化域名 [英] Redirect to other domain but keep typed domain
问题描述
在寻找在互联网上大约一个小时,我没有找到答案,我的问题。所以我在寻找与错误的关键字或什么,我想是不可能的。
After looking on the internet for about an hour, I didn't find the answer to my question. So I'm searching with the wrong keywords or what I want is not possible.
我想:
我有多个域的不同扩展名,例如:
What I want:
I have multiple domains with different extensions, for example:
- mydomain.be
- mydomain.nl
现在我想的是,mydomain.be被重定向到mydomain.nl。为了这个,我发现在互联网上,如下图所示的解决方案,用的.htaccess的需要:
Now what I want is that the mydomain.be is redirected to mydomain.nl. The solution for this I have found on the internet and shown below, with the need of .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain.be$ [OR]
RewriteCond %{HTTP_HOST} ^www.mydomain.be$
RewriteRule (.*)$ http://www.mydomain.nl/$1 [R=301,L]
通过这个code,当你键入mydomain.be你将被重定向到mydomain.nl。而且在地址栏的URL变为mydomain.nl。我要的是保持URL的地址栏mydomain.be。
With this code, when you type mydomain.be you will be redirect to mydomain.nl. But also the URL in the addressbar is changed to mydomain.nl. What I want is to keep the URL in the addressbar mydomain.be.
所以,mydomain.be:
So, mydomain.be:
- 在保持网址
- mydomain.nl的展示内容
如何?
推荐答案
这是可能得到它通过mod_rewrite来实现,但要确保mod_proxy的是你的Apache的httpd.conf启用。通过的httpd.conf
一旦做到这一点使mod_rewrite的和.htaccess,然后把这个code在的.htaccess
在 DOCUMENT_ROOT
目录:
It is possible to get it done via mod_rewrite but make sure mod_proxy is enabled in your Apache's httpd.conf. Once that is done enable mod_rewrite and .htaccess through httpd.conf
and then put this code in your .htaccess
under DOCUMENT_ROOT
directory:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.be$ [NC]
RewriteRule ^ http://www.mydomain.nl%{REQUEST_URI} [L,NE,P]
拿笔记标记 P
这是用于处理代理请求。
Take note of flag P
which is used for handling the proxy request.
这篇关于重定向到其他域,但保持类型化域名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!