【问题标题】:Laravel the requested URL / was not found on this serverLaravel 请求的 URL / 在此服务器上找不到
【发布时间】:2017-12-26 09:10:57
【问题描述】:

我用 laravel 创建了一个网站,并将我的域转发到项目的文件夹中。但是,当我进入网站时,它显示错误:404 not found 在此服务器上找不到请求的 URL /

服务器.php:

<?php
$uri = urldecode(
    parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);

// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
    return false;
}

require_once __DIR__.'/public/index.php';

.htaccess:

<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>

索引.php:

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

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

编辑#1

我创建了一个 public_html 文件夹并将 laravel/public 的内容放在里面。将路径更改为使用“/../laravel/bootstrap/app.php”和“/../laravel/bootstrap/autoload.php”。当我现在进入网站时,它给了我 HTTP 500 错误

【问题讨论】:

  • "我用 laravel 做了一个网站,并将我的域名转发到项目的文件夹中。"您应该将域指向项目的 public 文件夹。 Laravel 项目的根目录中没有 index.php,它位于 public 目录中。
  • 基本上你是说你使用了 laravel 默认的 index.php 并从中删除了重要的东西?
  • 我没有,只是显示重要的行
  • 试试this 或this
  • 尝试更改项目所有者 chown -R www-data: *

标签: php laravel .htaccess hosting filezilla


【解决方案1】:

将更改后的文件恢复为默认值,并将您的虚拟主机指向public 文件夹。

【讨论】:

    猜你喜欢
    • 2015-03-30
    • 2016-11-23
    • 2015-12-17
    • 2016-12-21
    • 2016-07-23
    • 1970-01-01
    • 2017-03-21
    • 2010-10-16
    • 1970-01-01
    相关资源
    最近更新 更多