Laravel在此服务器上找不到请求的URL

时间:2017-07-20 15:07:48

标签: php laravel .htaccess hosting filezilla

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

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

的index.php:

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

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

编辑#1

我制作了一个public_html文件夹,并将laravel / public的内容放入其中。改变了使用&#39; /../ laravel / bootstrap / app.php&#39;的路径。和&#39; /../ laravel / bootstrap / autoload.php&#39;。当我现在进入网站时,它会给我HTTP 500错误

1 个答案:

答案 0 :(得分:1)

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