[英]laravel htaccess allow directory
I have a password protected directory at example.com/staging
. 我在
example.com/staging
有一个受密码保护的目录。
If I enter example.com/js
I get a folder listing. 如果输入
example.com/js
一个文件夹列表。
But if I enter example.com/staging
, I get a 404 error page generated by the Laravel site at example.com
(not example.com/staging
), rather than a password box. 但是,如果输入
example.com/staging
,则会得到Laravel网站在example.com
上生成的404错误页面(不是example.com/staging
),而不是密码框。 Why is this? 为什么是这样?
Here is my .htaccess file in the public_html folder (the home directory) at example.com
: 这是
example.com
public_html文件夹(主目录)中的.htaccess文件:
AddType application/x-httpd-php70 .php
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,QSA,NC,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# 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 my .htaccess file at example.com/staging
: 而我的.htaccess文件位于
example.com/staging
:
AuthType Basic
AuthName "Staging"
AuthUserFile "/home/example/.htpasswds/public_html/staging/passwd"
require valid-user
Remove the quotation marks from the directory path for AuthUserFile
, those shouldn't be there. 从
AuthUserFile
的目录路径中删除引号,这些引号不应位于该引号中。
Your directory path looks odd too, your .htpasswd
file shouldn't be located in the middle of the path, but should be at the end. 目录路径也看起来很奇怪,您的
.htpasswd
文件不应位于路径的中间,而应位于路径的末尾。 For example: 例如:
AuthUserFile /this/is/your/dir/.htpasswd
I'm sure it is, but as an added point, you are encrypting your password correctly? 我确定是的,但是要补充一点,您是否正确加密了密码? Apache will not accept a password that has not been correctly encrypted.
Apache将不会接受未正确加密的密码。 You can use this website to help with that if required: http://www.htaccesstools.com/htpasswd-generator/
如果需要,您可以使用此网站来提供帮助: http : //www.htaccesstools.com/htpasswd-generator/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.