2014-09-25 101 views
0

上我有,我已經創建了一個簡單的管理部分中的博客。我決定使用Laravel的基本認證實現,因爲我是唯一需要訪問的人。這對我本地工作很好,但是當我將我的代碼推送到服務器時,它不允許我進行身份驗證。Laravel的HTTP基本驗證本地工作,但不能遠程服務器

要解決這個問題,我首先SSH到我的服務器和嘗試以下操作:

  1. 運行php artisan key:generate
  2. 運行php artisan tinker
  3. $user = new User;
  4. $user->email = '[email protected]';
  5. $user->username = '[email protected]';
  6. $user->password = Hash::make('1234');
  7. $user->save();
  8. 確認數據庫條目如下權利:4|[email protected]|[email protected]|xxxxxxxxxxxxx|2014-09-25 14:07:20|2014-09-25 14:07:20
  9. 嘗試進行身份驗證

我啓用了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> 

但是,它仍然無法正常工作。任何建議,我可以嘗試調試這個?

謝謝! 馬特

回答

0

我只是在這個絆倒自己,意識到我是編輯錯誤的.htaccess - 一個在根文件夾中。在公共/文件夾中編輯.htaccess,你應該很好。

+0

@ tarazed84最後我只是用我使用的是標準的authentication.The .htaccess文件是在我的公開目錄。我也用它來緩存我的資源(CSS,腳本和圖像),所以我能夠驗證它的工作。 – 2015-03-06 14:36:20

相關問題