1
votes

I made a website with laravel and forwarded my domain to the folder of the project. However when I enter the website it shows me the error: 404 not found The requested URL / was not found on this server

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

EDIT #1

I made a public_html folder and placed the contents of laravel/public in it. changed the paths to use '/../laravel/bootstrap/app.php' and '/../laravel/bootstrap/autoload.php'. When I enter the website now it gives me the HTTP 500 error

1
"I made a website with laravel and forwarded my domain to the folder of the project." You should be pointing the domain at the project's public folder. There's no index.php in the root of a Laravel project, it lives in the public directory.ceejayoz
Basically you're saying you took the laravel default index.php and removed the important things from it?apokryfos
I did not, just showing the important linesjordibenck
Try this or thisMaraboc
Try to change project owner chown -R www-data: *erashdan

1 Answers

1
votes

Revert the changed files to their defaults and point your virtual host to the public folder.