laravel5上的HTTPS没有完全正常工作

时间:2016-08-04 23:29:16

标签: apache .htaccess laravel https laravel-5

我一直在努力让Apache在Laravel上运行。

  1. 当Laravel应用程序使用HTTPS时,路由不再有效。
  2. Expected:路线加载视图 Result: 404找不到页面。
    Note:这可以在没有https的情况下运行。

    这是我的apache2 conf

    <VirtualHost *:80>
        ServerAdmin email@something
        ServerName dev.something
    
        DocumentRoot /var/www/something/development/public_html
        DirectoryIndex index.php
    
    
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    
        Options -Indexes
        <Directory "/var/www/something/development/public_html/">
                Options FollowSymLinks
                AllowOverride All
                Order allow,deny
                Allow from all
    
                AuthUserFile /var/www/something/.htpasswd
                AuthName "Password please"
                AuthType Basic
                Require valid-user
        </Directory>
    

    这是我的.htaccess

    <IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>
    
    RewriteEngine On
    
    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]
    
    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    
    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
    # Force SSL
    RewriteCond %{HTTPS} !=on
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    

    以下代码强制laravel5进入安全模式 应用程序/提供者/ AppServiceProvider.php

    public function boot()
    {
        \URL::forceSchema('https');
    }
    
    1. 像Barryvdh \ Debugbar这样的软件包无法再加载其资源。
    2. 老实说,我不再知道如何做到这一点。

      如果您对此有所了解,请回复!

0 个答案:

没有答案
相关问题