.htaccess issues, routes work with index.php on ubuntu 20.04 server
I am running a Laravel 9 application on Ubuntu 20.04. Web server is Apache (Apache2) The application opens nicely, on the default route " route('/') ".
All other routes work only if appended with "index.php". I have tried multiple versions of the .htaccess file but failing to sort this out. Please assist.
Here is the default .htaccess file with the the installation
Options -MultiViews -IndexesRewriteEngine 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]
#Sort the index.php routing issue where all routes require the path to have index.php
@charlesmun In my opinion, your .htaccess file does not have permission in apache so you can check this to solve your problem.
go to /etc/apache2/apache2.conf (this may be different in your system find the apache config file in your server ) and search for AllowOverride and you find this for /var/www
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
you must change None to All.
I should mention if you have a shared host this is different.
Please or to participate in this conversation.