在.htaccess,重定向所有领域除一人外 [英] In .htaccess, redirect all domains except one
问题描述
我有我的服务器上的多个域。我想重定向他们都一(example.net)。
I have multiple domains on my server. I want to redirect all of them to one (example.net).
我的.htaccess:
My .htaccess:
RewriteEngine on
RewriteRule ^(.*)$ http://www.example.net/$1 [R=301,L]
我在我的重定向服务器到一个主域名的所有网址,但该领域也重定向到自身。所以www.example.net返回 301永久移动
和重定向回自己。有人告诉我,这是不利于搜索引擎优化。我怎么能解决这个问题?
I’m redirecting all URLs on my server to one main domain, but that domain is also redirecting to itself. So www.example.net returns 301 Moved Permanently
and redirects back to itself. I’m told that this isn’t good for SEO. How could I fix this?
推荐答案
您需要从当你已经在你想要的域名重定向添加的的RewriteCond 的以prevent它。如果你google一下,或者看到Apache的mod_rewrite文档的的RewriteCond节有实例负载在线一>。
You need to add a Rewritecond to prevent it from redirecting when you’re already on the domain that you want. There are loads of examples online if you google it, or see the RewriteCond section of Apache’s mod_rewrite documentation.
您正在寻找的是这样的:
What you’re looking for is something like:
RewriteEngine on
Rewritecond %{HTTP_HOST} !^www\.example\.net
RewriteRule ^(.*)$ http://www.example.net/$1 [R=301,L]
这篇关于在.htaccess,重定向所有领域除一人外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!