Laravel 5 + XAMPP: remove PUBLIC in URL

If you are installing or running your Laravel application in XAMPP environment you will probably access your application in the browser in this format localhost/yourApp/public

I haven’t try this out with WAMP or MAMP but I think this will work

Of course you can use php artisan serve which is the default development server of Laravel. But you will have to maintain or keep it running.

The steps are very

First, in your root directory, rename your server.php to server.php.bak, this will keep your original file in case something went wrong.

Next save (server.php.bak) as index.php in your root directory.

Now, create a new file in your root directory and name it .htaccess.

Copy this code

In case you are using asset() to define links and scripts. You must put ‘public’ at the beginning eg. {{ asset(‘public/images’) }} 

Now you can directly access your application in the browser eg. localhost/myApp

Sharing is caring!