首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当试图到达HTTP请求时,Laravel路由被毁

当试图到达HTTP请求时,Laravel路由被毁
EN

Stack Overflow用户
提问于 2019-12-20 06:24:47
回答 1查看 58关注 0票数 0

目前,我已经成功地设置了我的Laravel Passport API

使用Laravel 5.8

我的api有这个httpd-vhosts.conf配置

港口: 80

代码语言:javascript
复制
<VirtualHost *:80>
ServerName <sub-domain>.<domain>.com
ServerAlias <sub-domain>.<domain>.com
Redirect permanent / https://<sub-domain>.<domain>.com
</VirtualHost>

港口: 443

代码语言:javascript
复制
 <VirtualHost *:443>
   DocumentRoot "/opt/lampp/htdocs/api_tk/public"
   <Directory "/opt/lampp/htdocs/api_tk/public">
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      allow from all
   </Directory>
   ServerName <sub-domain>.<domain>.com
   ServerAlias <sub-domain>.<domain>.com

   ErrorLog "logs/API-error_log"
   CustomLog "logs/API-access_log" common

   ProxyPreserveHost On
   ProxyRequests Off
   ProxyPassMatch /fingerprint http://localhost:5000
   ProxyPassReverse /fingerprint http://localhost:5000
   RequestHeader set X-Forwarded-Proto https
   RequestHeader set X-FOrwarded-Port 443

   SSLEngine on
   SSLCertificateFile "/opt/lampp/htdocs/ssl_key/svs-file.crt"
   SSLCertificateKeyFile "/opt/lampp/htdocs/ssl_key/private_new.key"
   SSLCACertificateFile "/opt/lampp/htdocs/ssl_key/svs-bundle-file.crt"
</VirtualHost>

443工作正常我可以在浏览器上看到我的HTTPS SSL锁号

当我尝试做HTTP请求时

拉勒维尔API总是被毁了。

我有这样的路线

https://..com/api/login

这一切都很好

但是当我尝试像这样做HTTP请求时

http://<sub-domain>.<domain>.com/api/login

最后总是

https://<sub-domain>.<domain>.comapi/login

斜线不见的地方。这是因为我的端口80配置上的redirect permanent

我的api有这条路。(api.php)

代码语言:javascript
复制
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});


Route::post('/timekeeping','Auth\Api\AuthController@timekeeping');

Route::post('/login','Auth\Api\AuthController@login');

Route::middleware('auth:api')->group(function () {

Route::post('/timekeeping_app','Auth\Api\AuthController@timekeeping_app');

Route::post('/logout','Auth\Api\AuthController@logout');

Route::post('/register','Auth\Api\AuthController@register');

Route::post('/show_dtr_list','Auth\Api\AuthController@show_dtr_list');

Route::post('/update','Auth\Api\AuthController@update');

Route::post('/delete','Auth\Api\AuthController@delete');

Route::post('/search_user','Auth\Api\AuthController@search_user');

Route::get('/current_time','Auth\Api\AuthController@current_time');

});

我怎么才能阻止这一切?

更新

尝试像这样编辑我的vhost配置

Redirect permanent "/" "https://<sub-domain>.<domain>.com/"

Redirect permanent / https://<sub-domain>.<domain>.com\/

但这给了我这样的输出

EN

回答 1

Stack Overflow用户

发布于 2019-12-20 06:31:43

请尝试在apache虚拟主机设置下添加斜杠:

代码语言:javascript
复制
<VirtualHost *:80>
ServerName <sub-domain>.<domain>.com
ServerAlias <sub-domain>.<domain>.com
# fix below
Redirect permanent / https://<sub-domain>.<domain>.com/
</VirtualHost>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59420720

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档