0
上我有,我已經創建了一個簡單的管理部分中的博客。我決定使用Laravel的基本認證實現,因爲我是唯一需要訪問的人。這對我本地工作很好,但是當我將我的代碼推送到服務器時,它不允許我進行身份驗證。Laravel的HTTP基本驗證本地工作,但不能遠程服務器
要解決這個問題,我首先SSH到我的服務器和嘗試以下操作:
- 運行
php artisan key:generate
- 運行
php artisan tinker
$user = new User;
$user->email = '[email protected]';
$user->username = '[email protected]';
$user->password = Hash::make('1234');
$user->save();
- 確認數據庫條目如下權利:
4|[email protected]|[email protected]|xxxxxxxxxxxxx|2014-09-25 14:07:20|2014-09-25 14:07:20
- 嘗試進行身份驗證
我啓用了FastCGI的,所以增加了對每Laravel的文檔,我的.htaccess文件的附加要求:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule^index.php [L]
# HTTP Authentication if FastCGI is enabled
RewriteCond %{HTTP:Authorization} ^(.+)$
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType text/css "access plus 2 hours"
ExpiresByType application/javascript "access plus 2 hours"
ExpiresByType application/x-font-woff "access plus 2 hours"
ExpiresByType font/truetype "access plus 2 hours"
ExpiresByType font/opentype "access plus 2 hours"
ExpiresByType image/png "access plus 2 hours"
</IfModule>
</IfModule>
但是,它仍然無法正常工作。任何建議,我可以嘗試調試這個?
謝謝! 馬特
@ tarazed84最後我只是用我使用的是標準的authentication.The .htaccess文件是在我的公開目錄。我也用它來緩存我的資源(CSS,腳本和圖像),所以我能夠驗證它的工作。 – 2015-03-06 14:36:20