简体   繁体   中英

Error: The requested URL /login was not found on this server. (Laravel)

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).

在此处输入图片说明

Public folder:

在此处输入图片说明

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

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

htaccess

To:

.htaccess

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM