CentOs7上的Laravel路由错误404(未找到) [英] Laravel route error 404(Not Found) on CentOs7

查看:347
本文介绍了CentOs7上的Laravel路由错误404(未找到)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了laravel项目,该项目在我的本地Windows pc上运行良好.一旦我(通过SSH)上传到Centos7服务器,我的所有路由都显示为未找到404, https://ibb.co/tHysggf '索引页除外.下图是我的项目结构.我删除公用文件夹,然后将index.php放在外面.

I created laravel project that work fine on my local windows pc. Once I upload to Centos7 server(via SSH), all my routes show 'Not Found 404, https://ibb.co/tHysggf ' except index page. Picture below is my project structure. I remove public folder and place index.php outside.

非常感谢所有答案.

推荐答案

1打开httpd.conf

1 Open httpd.conf

   sudo vim /etc/httpd/conf/httpd.conf

2确保DocumentRoot指向laravel项目的公共目录.按如下所示添加该路径的Directory元素和Allowoverride All ...

2 Make sure the DocumentRoot is pointing to the laravel project's public directory. Add the Directory element for that path and Allowoverride All... as follows

DocumentRoot "/var/www/html/laravel/public/"

<Directory "/var/www/html/laravel/public">
Allowoverride All
</Directory>

3从../laravel/public/中打开.htaccess,并确保它具有以下内容

3 Open .htaccess from ../laravel/public/ and make sure it has the following

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

4重新启动httpd服务

4 Restart httpd services

sudo service httpd restart

这篇关于CentOs7上的Laravel路由错误404(未找到)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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