问题
I have a project with Laravel and inside the public folder (httpdocs
) I have a folder /en/news
, all works fine with the route /en/news
but when I try to go to the /en
I have a 403 error because it is a empty folder, the real problem there is that /en
is a route in my Laravel project with the homepage of the web, so first executes de .htaccess
and throw the 403.
Is there any way to ignore this error for this specific folder/route (/en
) or something like that?
My .htaccess
is the tipical Laravel .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]
回答1:
The solution:
Add before the # Send Requests To Front Controller...
the next rewrite:
RewriteRule ^en/$ index.php [L]
This send the request to the index.php ignoring the checks for this specific route.
来源:https://stackoverflow.com/questions/63167421/ignore-the-empty-folder-403-and-pass-the-uri-to-the-laravel-controller-with-h