4

I'm having trouble setting up a .htpasswd protected laravel project.

I tried adding the following to my .htaccess but it causes an internal server error (500) after I entered my credentials..

.htaccess content:

AuthUserFile .htpasswd
AuthType Basic
AuthName "Secured area"
Require valid-user

<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}]
</IfModule>

And this is the current routes.php. Just in case it's something I should change in the routes.php:

Route::get('/', 'HomeController@index');

Route::auth();

Route::get('/home', 'HomeController@index');

I couldn't find anything useful on Google which still works under laravel 5.2 so I really hope someone out there has an idea :)

ThatMSG
  • 1,456
  • 1
  • 16
  • 27

1 Answers1

5

As @Olaf mentioned. changing this:

AuthUserFile .htpasswd

..into this:

AuthUserFile /absolute/server/path/.htpasswd

..did the trick. Thank you verry much!

ThatMSG
  • 1,456
  • 1
  • 16
  • 27