忽略空文件夹(403),然后使用.htaccess将URI传递给Laravel控制器 [英] Ignore the empty folder (403) and pass the URI to the Laravel controller with .htaccess
问题描述
我有一个带有Laravel的项目,并且在公用文件夹( httpdocs
)内,我有一个文件夹/en/news
,在路由/下都可以正常工作zh/news
,但是当我尝试转到/en
时,由于它是一个空文件夹,因此出现403错误,真正的问题是/en
是我的Laravel项目中带有网络主页的一条路线,因此首先执行de .htaccess
并抛出403.对于这个特定的文件夹/路由(/en
)或类似的东西,有什么方法可以忽略吗?
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?
我的 .htaccess
是典型的Laravel .htaccess
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]
推荐答案
解决方案:
在#向前端控制器发送请求...
之前添加下一个重写:
Add before the # Send Requests To Front Controller...
the next rewrite:
RewriteRule ^en/$ index.php [L]
这会将请求发送到index.php,而忽略了对此特定路由的检查.
This send the request to the index.php ignoring the checks for this specific route.
这篇关于忽略空文件夹(403),然后使用.htaccess将URI传递给Laravel控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!