htaccess for make live laravel live

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ ^$1 [N]

    RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
    RewriteRule ^(.*)$ public/$1

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ server.php
</IfModule>

This .htaccess code performs the following tasks:

  1. Enables Rewrite Engine: Activates the Apache mod_rewrite module for URL rewriting.
  2. Rewrites URLs to Public Directory: Directs all requests to the public directory, where Laravel’s front controller (index.php) resides.
  3. Handles Front Controller: Forwards all requests that do not match an existing file or directory to Laravel’s front controller (index.php or server.php).

Make sure to place this .htaccess file in the root directory of your Laravel project. Additionally, ensure that your Apache server configuration allows the use of .htaccess files and has the mod_rewrite module enabled.