laravel 配置全局採用https方式訪問

在框架啓動前 boot方法裏增長php

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //
        $this->app['request']->server->set('HTTPS',Request()->server('HTTP_HOST') != 'localhost');
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
相關文章
相關標籤/搜索