【问题标题】:500 server error while using 301 redirect使用 301 重定向时出现 500 服务器错误
【发布时间】:2014-01-03 22:28:27
【问题描述】:

我在 .htaccess 文件中尝试了以下几行并将其放入包含文件夹中:

//301 Redirect Old File
RewriteEngine on
Redirect 301 includes/config.php includes/index.php

我希望当任何用户使用 url 打开此文件时,他/她必须重定向到 include/index.php 文件。 但是我收到了 500 服务器错误。

【问题讨论】:

  • 向我们展示您的.htaccess 文件

标签: php apache .htaccess http-redirect


【解决方案1】:

您的 500 错误的原因是:Redirect to non-URL

由于您在匹配模式和目标 URL 中缺少前导斜杠。

使用此规则修复它:

Redirect 301 /includes/config.php /includes/index.php

【讨论】:

    【解决方案2】:

    尝试:

    Redirect 301 /includes/config.php http://yoursite.com/includes/index.php
    

    虽然,如果 htaccess 在包含目录中,那么您根本不需要 /includes。 第二个 url 也必须是完整的 - 如上所述。

    【讨论】:

      猜你喜欢
      • 2014-10-11
      • 2017-10-01
      • 2014-01-11
      • 2011-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多