【问题标题】:301 Permanent Redirect, Redirecting Incorrectly?301永久重定向,重定向不正确?
【发布时间】:2013-12-31 16:06:11
【问题描述】:

我正在尝试重定向尝试访问的流量:
cat.rs.allgames.com/cloud/11/services/titles/game5/console/file.json

至:
cat.cloud.allgames.com/titles/game5/console/file.json

在 .htaccess 文件中使用 301 永久重定向,但它总是将我发送到:
cat.cloud.allgames.comcloud/titles/game5/console/cloud/11/services/titles/game5/console/file.json

这远非正确。我做错了什么?

我的 .htaccess 位于:
cat.rs.allgames.com/cloud/11/services/titles/game5/console/file.json

看起来像这样:
Redirect 301 / http://cat.cloud.allgames.com

【问题讨论】:

  • 建议您切换到 RedirectMatch,因为Redirect 仅用于路径的精确匹配
  • 我觉得我应该为此使用 ProxyPass。请原谅我缺乏经验,但我不确定在哪里使用我的 ProxyPass 命令。在 httpd.conf 文件中吗?
  • 我不知道如何使用ProxyPass

标签: redirect http-status-code-301


【解决方案1】:

重写模块应该做你想做的事!您需要确保启用了重写模块(对于 ubuntu:sudo a2enmod rewrite),然后将其添加到您的 .htaccess 文件中。

RewriteEngine On
RewriteRule ^/cloud/11/services/titles/(.*)$ http://cat.cloud.allgames.com/titles/$1 [R=301]

在这里,^/cloud/11/services/titles/(.*)$ 捕获 URL 标题部分之后的任何内容。然后第二部分末尾的$1 将我们捕获的内容附加到新 URL 的末尾。最后,您可以使用[R=301] 标志将其指定为对另一台服务器的外部301 重写!

希望对你有用!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-24
    • 2013-07-17
    • 1970-01-01
    • 1970-01-01
    • 2012-05-31
    • 2015-08-11
    • 1970-01-01
    • 2012-02-24
    相关资源
    最近更新 更多