Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jeevamugunthan's avatar

Larvel application not working witout index.php

Hi I'm facing a new problem in laravel application. the application is not working when we reach the url

http://moodlereport.kgm.in/login // not working

If we put index.php in the url its working fine

http://moodlereport.kgm.in/index.php/login

The server path is var/www/html/foldername

mod_rewrite is enabled in the server

here is my .htaccess file content located in root dictionary

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ / [L,R=301]

# Handle Front Controller...
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

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

<Files .env>
    Order allow,deny
    Deny from all
</Files>

<Files .zip>
    Order allow,deny
    Deny from all
</Files>

Under public folder there is no .htaccess file.

Please help me to resolve this, Thanks in advance.

0 likes
2 replies
s4muel's avatar

1 - the apache host/document root needs to point to the public directory, not the root folder of your project.

2 - the .htaccess needs to be in the public directory

3 - RewriteRule ^(.*)/$ / [L,R=301] <- this seems a bit off, dont you miss the $1 there after the slash? RewriteRule ^(.*)/$ /$1 [L,R=301]

jeevamugunthan's avatar

Hi @s4muel , Thanks for your reply.

I have pointed apache to the public directory and move the index.php and .htaccess to public folder

Here is my new .htaccess file

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Redirect all requests with "public/public" in the URL to the correct path
    RewriteRule ^public/(.*)$ / [L,NC,R=301]

    # Redirect all non-existent files or directories to index.php
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Remove "index.php" from URLs
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/index\.php/(.*)$ // [L,R=301]
</IfModule>


<Files .env>
    Order allow,deny
    Deny from all
</Files>

<Files .zip>
    Order allow,deny
    Deny from all
</Files>

$1 is avaliable in code its not showing after paste the code in this. RewriteRule ^public/(.*)$ /$1 [L,NC,R=301] Still i'm facing the problem

Please or to participate in this conversation.