.htaccess 生产中出现NotFoundHttpException管腔

wydwbb8l  于 2022-11-16  发布在  其他
关注(0)|答案(1)|浏览(134)

当访问Api时,返回打印如下:Symfony\组件\Http内核\异常
找不到Http异常enter image description here
项目位于“back”文件夹中,URL为api/
根目录.htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

RewriteRule ^api(/(.*))?$ back/public/$1 [L]

RewriteRule ^(.*) $1.php [NC,L]

公共选项-多视图-索引中的.htaccess

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]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
vsdwdz23

vsdwdz231#

对于这个问题,我认为您需要在应用程序的服务容器中添加一个请求捕获。
为此,您需要将此代码添加到public/index.php

$request = IlluminateHttpRequest::capture();
$app->run($request);

或者,您也可以通过将此代码放入同一个文件中来执行另一个解决方案

$app->run($app->make('request'));

相关问题