多个停放域的重定向不适用于文件名 [英] The Redirection of Multiple Parked Domains doesn't Work with Filename

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

问题描述

我的问题对我来说似乎很简单,但我找不到简单的解决方案.这是:我有一个主域,多个域指向该主域.为了避免重复内容,我试图将所有辅助"或停放"域重定向到我的主域,以便它解析为:

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 代码是一个包罗万象的解决方案(我更喜欢):

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]

所以当我只处理简单的停放域,而不是处理带有子文件夹或子文件的停放域时,此代码有效.所以:

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天全站免登陆