【问题标题】:Laravel .htaccess file setup?Laravel .htaccess 文件设置?
【发布时间】:2018-04-20 16:57:47
【问题描述】:

我想部署一个 laravel 项目,但是当我单击某个链接/路由时,我一直收到内部服务器错误 500。我坚信这是.htaccess 文件。默认文件看起来像这样,我不知道我需要如何修改它。

在我的 ftp 服务器上,我这样设置: 网络空间已连接到 /raidsystem/public_html/ .htaccess 位于 _public_html_ 中,另一个文件夹名为“lsapp”,位于 /raidsystem/ 中,因此如下所示:

/raidsystem/lsapp/

/raidsystem/public_html/.htaccess

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

    RewriteEngine On

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

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

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

【问题讨论】:

  • 在公共目录中显示index 文件的代码。以及你的服务器的目录结构
  • &lt;?php define('LARAVEL_START', microtime(true)); require __DIR__.'/lsapp/vendor/autoload.php'; $app = require_once __DIR__.'/lsapp/bootstrap/app.php'; $kernel = $app-&gt;make(Illuminate\Contracts\Http\Kernel::class); $response = $kernel-&gt;handle( $request = Illuminate\Http\Request::capture() ); $response-&gt;send(); $kernel-&gt;terminate($request, $response);
  • raidsystem/lsapp/vendor/autoload.php
  • raidsystem/public_html/index.php raidsystem/public_html/.htaccess Webspace 已连接到 public_html

标签: php laravel .htaccess deployment


【解决方案1】:

在你的条件下

raidsystem/public_html/ 中的 index.php 文件需要更改

require __DIR__.'/lsapp/bootstrap/autoload.php';

$app = require_once __DIR__.'/lsapp/bootstrap/app.php';

【讨论】:

  • 然后我收到以下错误: 致命错误:require(): 无法打开所需的 '/homepages/10/d694923868/htdocs/raidsystem/public_html/lsapp/bootstrap/autoload.php' (include_path= '.:/usr/lib/php7.2') 在 /homepages/10/d694923868/htdocs/raidsystem/public_html/index.php 第 24 行我的 autoload.php 顺便说一句在 /lsapp/vendor/autoload.php 我已在提供程序控制面板上更改为 php 7.2。
  • 你使用的是哪个 laravel 版本
  • 我的是 5.4 检查您的 require() 方法是否指示正确的目录/文件。检查 bootstrap 目录中的autoload 文件,否则它将位于根目录的 vendor 目录中。
  • 此错误仅对正确位置的文件更正有关。
  • autoload.php 正确指向require_once __DIR__ . '/composer/autoload_real.php'; 自动加载文件在 lsapp/vendor 里面 bootstrap 我只有一个缓存文件夹和一个 app.php
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-15
  • 2020-07-17
  • 1970-01-01
  • 2012-08-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多