在.htaccess重定向多个域名一个 [英] redirecting several domains to one in .htaccess

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

问题描述

我想补充一些code到我的.htaccess重定向到几个不同的领域,以单个域。我见过code,将一个域做到这一点,如:

I would like to add some code to my .htaccess to redirect several different domains to a single domain. I have seen code that will do this for one domain such as:

RewriteCond %{HTTP_HOST} ^www\.example\.net  
RewriteRule (.*) http://www.example.com/$1 [R=permanent,QSA,L]

但是,什么是有重定向到一个域多个域的最佳方法?

But what is the best approach to have multiple domains redirected to a single domain?

推荐答案

只有重定向如果域的没有的要重定向到一个:

Only redirect if the domain is not the one you want to redirect to:

RewriteCond %{HTTP_HOST} !(^www\.example\.com$)  
RewriteRule (.*) http://www.example.com/$1 [R=permanent,QSA,L]

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

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