Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess Laravel 5.2-使用.htpasswd进行基本身份验证_.htaccess_Laravel_Laravel 5 - Fatal编程技术网

.htaccess Laravel 5.2-使用.htpasswd进行基本身份验证

.htaccess Laravel 5.2-使用.htpasswd进行基本身份验证,.htaccess,laravel,laravel-5,.htaccess,Laravel,Laravel 5,设置.htpasswd保护的laravel项目时遇到问题 我尝试将以下内容添加到.htaccess中,但在我输入凭据后,它会导致内部服务器错误(500) .htaccess内容: AuthUserFile .htpasswd AuthType Basic AuthName "Secured area" Require valid-user <IfModule mod_rewrite.c> <IfModule mod_negotiation.c>

设置.htpasswd保护的laravel项目时遇到问题

我尝试将以下内容添加到.htaccess中,但在我输入凭据后,它会导致内部服务器错误(500)

.htaccess内容:

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>

我在谷歌上找不到任何有用的东西,因为它仍然在Laravel5.2下工作,所以我真的希望有人有个想法:)

正如@Olaf所提到的。更改此选项:

AuthUserFile .htpasswd
…在这方面:

AuthUserFile /absolute/server/path/.htpasswd

…成功了。非常感谢你

htpasswd出现内部服务器错误,请参阅,我也有相同的问题。我还提到了
htpasswd
full path
,但不起作用。您的
.htaccess
文件是否也在
public
中?不-我不想冒任何风险我们如何只允许API?并使用.htpasswd限制web访问?
AuthUserFile /absolute/server/path/.htpasswd