如何重定向域中使用htaccess的子域? [英] How do I redirect domain to subdomain using htaccess?

查看:197
本文介绍了如何重定向域中使用htaccess的子域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的.htaccess是一个有点新的我!

.htaccess is a bit new to me!

我有位于www.domain.com当前的网站,我要建一个新的网站new.domain.com。

I have a current site located at www.domain.com and I'm building a new site at new.domain.com.

在新网站完成后,我想重新定向所有的流量到新的子域。

When the new site is finished, I want to re-direct all traffic to the new subdomain.

另外,我想解决URL规范化的同时。

Also, I want to resolve url canonicalization at the same time.

任何帮助AP preciated! 谢谢 马克

Any help appreciated! Thanks Mark

推荐答案

有几种不同的解决方案。最好的一个,无论是从搜索引擎优化和用户的角度来看,是一比一301重定向。它preserves你的链接汁,并在同一时间在客户端重定向到新网站上的准确位置。

There are several different solutions. The best one, both from SEO and User perspective, is the one-to-one 301 redirect. It preserves your link juice and at the same time redirects the client to the exact location on the new website.

如果您有mod_alias中启用了,我会建议一个简单的

If you have mod_alias enabled, I would suggest a simple

RedirectMatch 301 ^(.*)$ / http://new.domain.com/$1

结果指令可以完成与

The result instruction can be accomplished with

RewriteEngine On
RewriteRule (.*) http://new.domain.com/$1 [R=301,L]

第二个是最好的选择,如果你需要把多个条件和过滤器。例如,如果您需要重定向取决于用户代理头只有某些主机或客户端。

The second one is the best choice if you need to chain multiple conditions and filters. For example, if you need to redirect only certain hosts or clients depending on User Agent header.

记住:mod_redirect花费precedence超过mod_alias中

Remember: mod_redirect takes precedence over mod_alias.

这篇关于如何重定向域中使用htaccess的子域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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