First make sure you already create Laravel 10 project, see Laravel 10 Installation Guide.
This is useful to make your url accessible without navigating to /public
folder.
-
Create a
.htaccess
file and put it in your root folder of your project with the content below.# this file must be in the root directory of your project <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews -Indexes </IfModule> RewriteEngine On # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} -d [OR] RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^ ^$1 [N] RewriteCond %{REQUEST_URI} (\.\w+$) [NC] RewriteRule ^(.*)$ public/$1 # Send Requests To Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule>
-
Create new file named
index.php
in root folder of your project and with the content below:<?php require_once('public/index.php');
-
[OPTIONAL] Put
LivewireController.php
file to yourapp/Http/Controllers
folder inside your project with the content below. Used in a case where for example, you are working with xampp and put the project inside the htdocs folder. Obviously you would access the site by the urlhttp://localhost/chirper
instead ofhttp://localhost:<port>
. Keep in mind, you need to change the$baseUrl
value fromchirper
to your project path relative to the host.This is OPTIONAL step, if you are not supposed to use Livewire, you shouldn't need to use the
LivewireController
and skip this step.<?php // this file must be placed in the app/Http/Controllers namespace App\Http\Controllers; use Illuminate\Support\Facades\Route; use Livewire\Livewire; /** * This controller is necessary to extend only if you are working in subdirectory of the root host. * For example, you are working with xampp and put the project inside the htdocs folder. * Obviously you would access the site by the url {@code http://localhost/chirper} instead of {@code http://localhost:<port>}. * Otherwise you don't need to extend this controller. */ class LivewireController extends Controller { /** * @link https://livewire.laravel.com/docs/installation#configuring-livewires-update-endpoint * @link https://livewire.laravel.com/docs/installation#customizing-the-asset-url */ public function __construct() { // change the $baseUrl to your current sub directory $baseUrl = '/chirper'; // set liveware asset route to look into custom base url Livewire::setScriptRoute(function ($handle) use ($baseUrl) { return Route::get($baseUrl . '/livewire/livewire.js', $handle); }); // set liveware update route to look into custom base url Livewire::setUpdateRoute(function ($handle) use ($baseUrl) { return Route::post($baseUrl . '/livewire/update', $handle); }); } }