Laravel 5返回404错误的每一页 [英] Laravel 5 returns 404 error for every page

查看:245
本文介绍了Laravel 5返回404错误的每一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有麻烦配置Apache和我的项目的.htaccess文件。我将它存储在在/ var / www / html等子文件夹,并通过Apache走样了。我还添加了的RewriteBase到我的.htaccess文件。访问的别名(server.ip /博客)列出公共目录,但一切我尝试访问返回404错误。任何想法?

I am having trouble configuring Apache and my project's .htaccess file. I am storing it in a subfolder in /var/www/html, and aliasing it via Apache. I have also added RewriteBase to my .htaccess file. Accessing to the alias (server.ip/blog) lists the public directory, but everything I try to access returns a 404 error. Any ideas?

的.htaccess:

.htaccess:

Options +FollowSymLinks
RewriteEngine On

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

Apache站点的.conf:

Apache site .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>

在此先感谢!

Thanks in advance!

推荐答案

首先,请从的index.php 斜线,并移动的RewriteBase 了:

Firstly, remove the slash from /index.php, and move your RewriteBase up:

的.htaccess 文件应该被保存在你的博客目录,并应包含以下内容:

Your .htaccess file should be saved in your blog directory and should contain the following:

RewriteEngine on
RewriteBase /blog/

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

选项+了FollowSymLinks 并不需要在该文件中的配置已经有了它建立起来。

Options +FollowSymlinks does not need to be in that file as the configuration already has it set up.

如果您使用的是Apache 2.4(而不是2.2),您的虚拟主机&LT;目录...&GT; 应该是这样的:

If you are using Apache 2.4 (as opposed to 2.2), your virtual host <directory...> should look like this:

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

此外,这并不需要在 CONF被复制文件。

这篇关于Laravel 5返回404错误的每一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆