阿帕奇 - 一个新的域名重定向 [英] Apache - redirecting with a new domain

查看:165
本文介绍了阿帕奇 - 一个新的域名重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有我们的网站上运行(说)stuff.com了一段时间,针对不同的应用子域的负载,red.stuff.com,blue.stuff.com当然还有内容的负载stuff.com/things/in/my/head

We've had our site running on (say) stuff.com for a while, with a load of sub-domains for different applications, red.stuff.com, blue.stuff.com and of course a load of content stuff.com/things/in/my/head

我们最近购买了新域名,awesome.com。

We've recently purchased a new domain, awesome.com.

我们可以配置Apache,以取代stuff.com在轮番上涨,与'awesome.com永久的要求吗?将这种方法保留任何搜索引擎列表和现有的链接是否有效?

Can we configure Apache to replace the 'stuff.com' in any request that turns up, with 'awesome.com' permanently? Would this method keep any search engine listings and existing links valid?

感谢

推荐答案

您可以使用Apache的的重写引擎。 (无论是在http.conf中或启用站点的目录)添加到您的虚拟主机配置:

You can use Apache's rewrite engine. Add this to your virtual server configuration (either in http.conf or in the sites-enabled directory):

RewriteEngine On
RewriteCond %{HTTP_HOST} stuff.com
RewriteRule ^(.*) %{HTTP_HOST}$1 [C]
RewriteRule ^(.*)stuff.com(.*) http://$1awesome.com$2 [R,L]

[C] 链中的两条规则在一起。第一条规则插入请求的域名到请求。下一条规则将请求重定向到新的域名,提取的子域,如有必要,URL的其余部分。

The [C] chains the two rules together. The first rule inserts the requested domain name into the request. The next rule redirects the request to the new domain name, extracting the subdomain and the rest of the URL if necessary.

应该重定向任何传入的请求(我和子域,文件和URL中的查询字符串测试过),所以搜索引擎的链接将仍然有效。我不知道它是如何影响搜索引擎排名,虽然。

It should redirect any incoming request (I tested it with subdomains, files, and query strings in the URL), so the search engine links would still work. I don't know how it affects search engine ranking, though.

这篇关于阿帕奇 - 一个新的域名重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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