2017-06-14 85 views
-1

我是Laravel框架的新手。除了主頁,其他頁面都會重定向到https,這在使用「php artisan serve」時不起作用。我檢查了routes.php和中間件,我無法在配置中找到任何強制https的東西。Laravel - 重定向到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 
+0

編輯您的問題並上傳.htaccess文件代碼 – 2017-06-14 09:47:46

+0

你的問題是在'.htaccess'文件 – 2017-06-14 09:50:17

+0

@Jadoon新增htaccess文件。 –

回答

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] 
+0

但在本地主機也重定向到https –

+0

@VivekSadh只是爲您的生產.htaccess文件 – Fahmi

+0

做到這一點,但我無法在本地主機上測試任何東西。它總是重定向到https。我必須手動將其更改爲http,然後才能正常工作。 –