1
votes

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/$1 [L] #relative substitution
RewriteRule ^ index.php

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]

note: i'm using linux elementary OS loki version Directory Structure

1
could you share your folder structure? - Sakibul Alam
like as laravel project folder structure. - Gabrielle-M
where did you setup the DOCUMENT_ROOT? Is it the public folder? or the root of the laravel project? Your document root should be the public folder. - Sakibul Alam
@SakibulAlam i'm update my question please see the directory structure - Gabrielle-M

1 Answers

0
votes

I think you need to add this to the GME directory .htaccess

RewriteEngine On
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]