skip to Main Content
PHP 7.4.9
Laravel 7.20.0
Appache 2.4.6
RedHat 7

I deployed my laravel project on the server and I am receiving the below error:

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

I tried almost all solutions that i found online.
The problem stayed the same.
mod_rewrite is enabled.
I added multiple line to httpd.conf and fix DocumentRoot

/etc/httpd/conf/httpd.conf

DocumentRoot "/var/www/html/chatbot/public"

<Directory "/var/www/html/chatbot/public">
        AllowOverride All
</Directory>

/var/www/html/chatbot/public/htaccess

<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]

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

Please note that when i try to link the DocumentRoot to a new laravel project, it works fine, but for the deployed code its not working(receiving the above error).

enter image description here

Public folder:

enter image description here

2

Answers


  1. Chosen as BEST ANSWER

    My problem was so silly. i Changed the folder name from:

    htaccess
    

    To:

    .htaccess
    

  2. laravel doc:

    If the .htaccess file that ships with Laravel does not work with your
    Apache installation, try this alternative:

    Options +FollowSymLinks -Indexes
    RewriteEngine On
    
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    

    read more

    after this apply and restart your apache server

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search