dtcn30461 2018-07-25 06:20
浏览 60

Laravel:使用SSL证书上传到服务器

Do i need to config some in codes before uploading to server with https:// because my problem is if we upload into production the pages are always not found. Someone told me that they didn't do anything in their code before uploading to server with https:// and it still working fine. I tried different things to make it work like configuring htaccess, AppServiceProvider and routes but its unfortunate.

.Htaccess

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews -Indexes
</IfModule>

RewriteEngine On

# Force SSL
RewriteCond %{HTTPS} off
RewriteRule (.*) https://hiflyer.ca/% [R,L]

# 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]

AppServiceProvider

    <?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //
        Schema::defaultStringLength(191);

    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
       if (env('APP_ENV') === 'production') {
        $this->app['request']->server->set('HTTPS', true);
       }
    }
}
  • 写回答

1条回答 默认 最新

  • donljt2606 2018-07-25 07:30
    关注

    correct, you need only config httaccess,it auto http->https, when enter http://----> https://, if database save http:// in rows, you need use Mysql replace http:// to https://

    RewriteEngine on
        RewriteCond %{HTTPS} !=on [NC]
        RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
        RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
        RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测