1

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

jordibenck
  • 175
  • 1
  • 4
  • 15
  • 2
    "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 Jul 20 '17 at 15:09
  • Basically you're saying you took the laravel default `index.php` and removed the important things from it? – apokryfos Jul 20 '17 at 15:13
  • I did not, just showing the important lines – jordibenck Jul 20 '17 at 15:17
  • 1
    Try [this](https://stackoverflow.com/questions/30198669/how-to-change-public-folder-to-public-html-in-laravel-5) or [this](https://laracasts.com/discuss/channels/servers/laravel-51-change-name-and-location-of-public-folder) – Maraboc Jul 20 '17 at 15:34
  • Try to change project owner chown -R www-data: * – erashdan Jul 20 '17 at 16:19

1 Answers1

1

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

kjdion84
  • 9,552
  • 8
  • 60
  • 87