Laravel - 重定向到https

时间:2017-06-14 09:40:43

标签: php laravel laravel-5

我是Laravel框架的新手。除了主页之外,每个其他页面都会重定向到https,这在使用“php artisan serve”时不起作用。我检查了routes.php和中间件我在强制https的配置中找不到任何这样的东西。

路线:

Route::group(array('prefix' => 'admin'), function() {


Route::controller('/form', 'Admin\FormController');
.....

............


Route::controller('/guide', 'Admin\GuideController');


Route::controller('/userlist', 'Admin\UserController');
Route::controller('/useradd', 'Admin\UserController');

Route::controller('/locationlist', 'Admin\LocationController');
Route::controller('/locationadd', 'Admin\LocationController');



Route::controller('/', 'Admin\AdminController');

});



Route::controller('/', 'Site\SiteController');

htaccess的:

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

    RewriteEngine On

    RewriteCond %{SERVER_PORT} 80 
    RewriteRule ^(.*)$ https://....../$1 [R,L]

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

</IfModule>

php_value post_max_size 200M
php_value upload_max_filesize 200M

1 个答案:

答案 0 :(得分:0)

你可以用htaccess解决。将这些代码粘贴到.htaccess文件中

    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

    RewriteCond %{HTTPS} !on
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]