【发布时间】:2022-01-12 08:29:39
【问题描述】:
我正在安装了 Apache24 和 PHP7.4 的 Windows 10 桌面上设置我的 Laravel vuejs 应用程序。
在我的 Windows 中安装 Apache24 和 PHP 后,当我访问 localhost:8080 时,它会加载网页主页,但是当我尝试在浏览器中访问 API 时,例如 GET localhost:8080/api/health,它会返回 404。
我做了php artisan route:list 并且路线存在。
我的项目文件的位置在“Apache24/htdocs”中
我已经为我的 httpd.conf 添加了如下虚拟主机
<VirtualHost *:8080>
DocumentRoot "C:/Apache24/htdocs/public"
ServerName "localhost"
<Directory C:/Apache24/htdocs/ >
AllowOverride All
</Directory>
</VirtualHost>
我的 routes/web.php 如下所示
Route::get('{any}', function ($any = null) {
if (strpos($any, 'shop/') === 0) {
return view('layouts.vue_shop');
} else {
return view('layouts.vue');
}
})->where('any', '^(?!api).*$');
我的路线/api.php
Route::get('health', 'HealthController')->name('api.check.health');
非常感谢任何建议。
【问题讨论】: