多重绑定域名的重定向不与文件名工作 [英] The Redirection of Multiple Parked Domains doesn't Work with Filename

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

问题描述

我的问题看似简单给我,但我无法找到一个简单的解决方案。这里有云:我有一个主域,多个域指向该主域。为了避免重复的内容我想重定向所有二级或停域名到我的主域名,以便它解析为这样的:

My problem seems simple to me but I cannot find a simple solution. Here goes: I have one main domain, and multiple domains pointing to that main domain. To avoid duplicate content I'm trying to redirect all "secondary" or "parked" domains to my main domain so that it resolves to this:

  • www.parkeddomain1.com => www.maindomain.com
  • www.parkeddomain2.com => www.maindomain.com
  • www.parkeddomain3.com => www.maindomain.com

等等...

现在我发现这个htaccess的code是那种一个包罗万象的解决方案(我将preFER)的:

Now I have found this htaccess code that is sort of a catch-all solution (which I would prefer):

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.maindomain.com$
RewriteRule ^(.*)$ http://www.maindomain.com/$1 [R=301]

所以这个code,当我只处理简单的域名停放,不与停放的域名与子文件夹或子文件工作。所以:

So this code works when I'm dealing only with straightforward parked domains, not with parked domains with subfolders or subfiles. So:

  • www.parkeddomain1.com => www.maindomain.com

重定向工作正常,在这里,但是当我添加子文件夹出现这种情况:

redirect works fine here but when I add a subfolder this happens:

  • www.parkeddomain1.com/subfolder/ => www.parkeddomain1.com/subfolder /

当我正在寻找的是:

  • www.parkeddomain1.com/subfolder/ => www.maindomain.com/subfolder /

所有此,为了避免重复的内容的问题与搜索引擎。

All this in order to avoid the duplicate content problem with search engines.

感谢所有的任何答案,将指引我到一个解决方案。

Thanks to all for any answer that would guide me to a solution.

干杯!

推荐答案

如果提问者开始重写与执政[R = 301] 301重定向,又名永久重定向的,然后他试图查看自己的URL的 www.parkeddomain1.com/subfolder / 的,但规则的结果不是他想要的,那么即使他尝试改变重定向规则,他的网络浏览器总是会重定向到URL在那里与重定向[R = 301] 标记的第一个URL。因为一旦浏览器被重定向永久到错误的地址,你甚至多少次编辑的规则,你的浏览器仍然会被重定向到旧地址,这是一个浏览器的东西,你甚至可能会在修复该规则,然后一遍更改规则却没有意识到它。改变了301重定向在您的浏览器可能需要较长的时间来证明了。

If the questioner starts rewrite ruling with [R=301] 301 redirect, a.k.a. "Permanently Redirect", and then he try to view his URL www.parkeddomain1.com/subfolder/ but the result of the rule wasn't what he want, then even he try to change the redirecting rule, his web browser will always redirect that URL into the first URL where it redirecting with [R=301] flag. Because once the browser has been redirected permanently to the wrong address, even how many times you edit the rule, your browser will still be redirected to the old address, that's a browser thing, and you may even go on to fix the rule, and then change the rule all over again without ever knowing it. Changes the 301 redirects in your browser can take a long time to show up.

的解决方案是重新启动的网络浏览器,或使用不同的一个。所以,如果你正在测试,最好用的 [R] 标记代替 [R = 301] 旗。而当你是100%肯定该规则不正是因为它的预期的话,就切换到 [R = 301] 标志。否则,这个问题属于服务器故障

The solution is to restart the web browser, or use a different one. So, if you're testing, it's better to use a [R] flag instead of [R=301] flag. And when you are 100% sure that the rule does exactly as it's expected to, then switch it to [R=301] flag. Or else, this question belongs to Server Fault.

这篇关于多重绑定域名的重定向不与文件名工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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