繁体   English   中英

Laravel 8 Cpanel 部署 - 404 错误

[英]Laravel 8 Cpanel Deploy - 404 Errors

我正在尝试将我的 Laravel 8 应用程序部署到 CPANEL 中的文件夹(我第一次部署 Laravel)。 我搜索了论坛并根据许多帖子直接进行了更改。 除了主页以及登录和注册页面之外,我在所有页面上都收到 404 错误。 这是一个常见错误,但我找不到解决方案。 不要拍我。

1.所有文件上传到url/laravel/blog

  1. 公用文件夹移出并重命名 public_html
  2. /laravel 文件夹现在有两个目录 /blog 和 /public_html
  3. public_html 文件夹中的 index.php 已更新:

需要DIR .'/../blog/vendor/autoload.php';

$app = require_once DIR .'/../blog/bootstrap/app.php';

  1. 新的 .htaccess 文件添加到 public_html 的根目录并设置为 chmod 755(详细如下)
  2. 重命名 /bootstrap 文件夹中的缓存文件夹,以便创建新的缓存(我希望)
  3. 数据库链接在 .env 文件中

我没有想法,我在公共文件夹中创建了一个测试 html 文件,当我导航到它时我可以在浏览器中看到它。 我正在学习,任何帮助将不胜感激。

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

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

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

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

在您的 .htaccess 中试试这个

DirectoryIndex index.php
<IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteBase /

    RewriteRule ^$ public/index.php [L]

    RewriteRule ^((?!public/).*)$ public/$1 [L,NC]

</IfModule>

我需要将子域/附加域指向公用文件夹。 无需移动任何东西或更改 Htaccess 等...... 归功于 https://stackoverflow.com/users/2325620/james-clark-developer

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM