【问题标题】:Laravel 5 returns 404 error for every pageLaravel 5 每页返回 404 错误
【发布时间】:2015-07-16 10:49:47
【问题描述】:

我在配置 Apache 和我的项目的 .htaccess 文件时遇到问题。我将它存储在 /var/www/html 中的子文件夹中,并通过 Apache 为其设置别名。我还将 RewriteBase 添加到我的 .htaccess 文件中。访问别名 (server.ip/blog) 会列出公共目录,但我尝试访问的所有内容都会返回 404 错误。有什么想法吗?

.htaccess:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /index.php [L]
RewriteBase /blog/

Apache 站点 .conf:

Alias /blog/ "/var/www/html/exoblog/public" 

<Directory "/var/www/html/exoblog/public/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
        Order allow,deny
    Allow from all
</Directory>

虚拟主机:

<VirtualHost *:80>
    ServerAdmin mymail@gmail.com
    DocumentRoot "/var/www/html/exoblog/public"
    ServerName eneko.dev
    ServerAlias www.eneko.dev
    ErrorLog "/var/log/apache2/exob.log"
    CustomLog "/var/log/apache2/exob.log" common

<Directory "/var/www/html/exoblog/public">
Options Indexes MultiViews FollowSymLinks
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>

</VirtualHost>

提前致谢!

【问题讨论】:

  • 请添加所有代码
  • 你添加到主机文件了吗??
  • 什么意思??它位于 /etc/apache2/sites-enabled/blog.conf
  • kristengrote.com/blog/articles/… 看看您是否已经按照给定链接中的所有步骤进行操作
  • 是的已经这样做了,我用 VirtualHost 更新了我的答案

标签: php apache .htaccess laravel


【解决方案1】:

首先,删除/index.php 的斜线,然后将RewriteBase 向上移动:

您的.htaccess 文件应保存在您的blog 目录中,并应包含以下内容:

RewriteEngine on
RewriteBase /blog/

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Options +FollowSymlinks 不需要在该文件中,因为配置已经设置好了。

如果您使用的是 Apache 2.4(而不是 2.2),您的虚拟主机 &lt;directory...&gt; 应该如下所示:

<Directory "/var/www/html/exoblog/public">
    Require all granted
    AllowOverride All
    Options Indexes Multiviews FollowSymLinks
</Directory>

另外,这不需要在conf 文件中复制。

【讨论】:

  • 好的,所以我刚刚进行了这些更改,我收到了 500 内部服务器错误。知道为什么吗?
  • 你运行的是什么版本的 Apache?
  • 我正在运行 2.4.7 版
  • 请查看/var/log/apache2/error.log的错误日志。
  • 我知道了:AH00124: 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.
猜你喜欢
  • 2014-05-08
  • 2018-04-03
  • 1970-01-01
  • 2018-12-08
  • 2018-02-11
  • 2015-04-07
  • 2018-12-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多