Question: I need to remove "public/index.php" or "index.php" from the generated URL in Laravel. Currently, it's in the format "localhost/public/index.php/someWordForRoute," but I want it to be "localhost/someWordForRoute." How can I achieve this?
Option 1: Using .htaccess
<IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^(.*)$ public/ [L] </IfModule>
Option 2: Moving Assets to the Root Directory
'app' => __DIR__.'/../app', 'public' => __DIR__.'/../public',
Replace it with:
'app' => __DIR__.'/../app', 'public' => __DIR__.'/../../',
require __DIR__.'/../bootstrap/autoload.php'; $app = require_once __DIR__.'/../bootstrap/start.php';
Replace it with:
require __DIR__.'/laravel_code/bootstrap/autoload.php'; $app = require_once __DIR__.'/laravel_code/bootstrap/start.php';
Source: How to remove /public/ from URL in Laravel
The above is the detailed content of How to Remove \'public/index.php\' from Laravel URLs?. For more information, please follow other related articles on the PHP Chinese website!