【问题标题】:Mod_Rewrite issue on shared hosting (Godaddy & Laravel 4)共享主机上的 Mod_Rewrite 问题(Godaddy 和 Laravel 4)
【发布时间】:2016-05-17 21:46:12
【问题描述】:

我在共享主机上遇到了 mod_rewrite 和 Laravel 4 的问题。

我已将 public 重命名为 lvrp。重命名本身很好,并且已经在我的本地主机上进行了测试。但是,当上传到 GoDaddy 时,它首先只是抛出了 500 错误。然后又找了一个.htaccess,改成这样:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

它可能不是最好的,但至少它有效。有点。

我可以访问起始页。我无法访问任何其他页面,除非我将 index.php 添加到 URI。使用 index.php,我可以访问每个页面。

关于如何在不添加 index.php 的情况下使其工作的任何想法?

编辑#1:

[error] [client x.x.x.x] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

这是我在 apache 日志中遇到的错误。

【问题讨论】:

  • 两个问题:1)您的托管服务器上启用了mod_rewrite? 2) 您是从根 URI 还是在虚拟目录下为您的 Web 应用程序提供服务?
  • mod_rewrite 确实已启用。我的网络应用程序位于 public_html/websites/domainname 中。它可以从 domain.com 访问。如果您明白我的意思,该域直接进入域名文件夹。 @RubensMariuzzo

标签: php apache mod-rewrite laravel


【解决方案1】:

关于如何在不添加 index.php 的情况下使其工作的任何想法?

它不需要 mod_rewrite。只需将此行添加到您的 .htaccess 顶部:

DirectoryIndex index.html index.php

这将使 apache 自动查找并呈现 index.html,否则 index.php 将显示在 DOCUMENT_ROOT 下的任何子目录中。

【讨论】:

    【解决方案2】:

    好吧,不知何故,我通过将项目移动到另一个目录来完成这项工作。

    Apache mod_rewrite(和正则表达式)仍然让我感到困惑。我不知道为什么它不起作用或为什么现在起作用。至少它按我想要的方式工作。

    对于其他有同样问题的人,我在搜索 Godaddy 和干净 url 的问题时发现了大量示例。希望对大家有所帮助。

    感谢您的回答。

    【讨论】:

      【解决方案3】:

      我知道它已经过时了,但我今天遇到了这个问题,为了解决它我改变了

      RewriteRule ^(.*)$ index.php/$1 [L]

      RewriteRule ^(.*)$ /index.php/$1 [L]

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-03-10
        • 2016-05-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多