John Davidson

php - web dev - server not pointing to laravel 7.3 public, displaying 'Index of /' page

0 comments
Message:


I have created a new laravel project in a fresh public_html dir on my work's server using


composer create-project laravel/laravel public_html

I have created the .vue component and the controller to display the homepage upon visiting the site but instead all that is displayed is this:


here is the web.php file for the handling the request:


<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', [HomepageContoller::class, 'index'])
->name('home');


here is the HomepageController class:


<?php

namespace App\HTTP\Controllers;

use Inertia\Inertia;

class HomepageContoller extends Controller {

public function index() {
return Inertia::render('Homepage/Index');
}
}

?>

and here is the .vue component:


<template>
<div>
<h1>Brite Visual Products<h1>
</div>
</template>

<script>
export default {
metaInfo: { title: 'Brite Visual Products' },
}
</script>

everything is exactly where it belongs, nothing has been moved since the composer create-project call


UPDATE:


it seems as though the issue is just that the web root is being pointed at public_html/ and not public_html/public/


to fix that i will need to have higher permissions on my work's server, will post a full solution later



My Answer:
If your server is not pointing to the Laravel 7.3 public directory and is displaying the directory listing instead, you may need to check the following:

1. Make sure that your server's document root is set to the public directory of your Laravel project. This can be done in the server configuration file (e.g., Apache's httpd.conf or Nginx's default file).

2. Check if the .htaccess file in the public directory is properly configured. Laravel comes with a default .htaccess file that should handle routing requests to the index.php file in the public directory.

3. Ensure that mod_rewrite is enabled on your server. This is necessary for the .htaccess file to work properly and route requests to the correct files.

4. Check the file permissions of the public directory and its contents. Make sure that the web server has the necessary permissions to access and execute the files.

5. Restart your web server after making any changes to the configuration files to ensure that the changes take effect.

If you have checked all of the above and are still experiencing issues, you may want to consult the Laravel documentation or seek help from the Laravel community for further assistance.

Rate this post

3 of 5 based on 6594 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us