Majeed
7 months ago

.htaccess file doesn't work properly in Laravel

Posted 7 months ago by Majeed

I'm working on a Laravel project. I'm Removing "/public" from URL but it's only work on welcome page, other page like /login,/register is doesn't work properly. it's shows an error.

The requested URL /GME/login was not found on this server.

Apache/2.4.18 (Ubuntu) Server at localhost Port 80

but when I use public/index.php in URL it's working.

http://localhost/GME/public/index.php/login

Here, is my root .htaccess file code.

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public/
    RewriteRule ^(.*)$ public/ [L] #relative substitution
    RewriteRule ^ index.php
</IfModule>

and here is my /public/.htaccess file code.

    <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
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

note: i'm using linux elementary OS loki version

Please sign in or create an account to participate in this conversation.