Trick to remove public/index.php from URL in Laravel

By | August 8, 2020

If you found “public/index.php/” in your project’s URLs and you want to remove that then, you will have to create an .htaccess file in your project’s root directory and you have to put below code in it and save the .htaccess file. However; you have to make sure that the ‘mod_rewrite’ module is enabled on your server. If it’s not then .htaccess code will not work.

Open your .htaccess file from your Laravel project root directory and place this code and save it.

   RewriteEngine On 
   RewriteRule ^(.*)$ public/$1 [L]

Now, you can access your URLs without “public/index.php”.


Leave a Reply

Your email address will not be published. Required fields are marked *