如何一个域重定向到另一个 [英] How to redirect one domain to another
本文介绍了如何一个域重定向到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个领域:
www.example1.com/ --> IP=1.2.3.4
www.example2.com/ --> IP=1.2.3.4 (same IP for both domains)
我想要去 www.example2.com / *所有请求
来访问请求的网页。
我想要去 www.example1.com / *
来重定向到 www.example2.com / *
所有的请求。我怎么会做这样的阿帕奇?正如现在我正在做这在JavaScript。
I want all requests that go to www.example2.com/*
to access the requested page.
I want all requests that go to www.example1.com/*
to redirect to www.example2.com/*
. How would I do this in apache? As now I am currently doing this in javascript.
推荐答案
把这个code在 DOCUMENT_ROOT /的.htaccess
文件:
put this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example1\.com [NC]
RewriteRule ^ http://www.example2.com%{REQUEST_URI} [NE,R=301,L]
这篇关于如何一个域重定向到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文