Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/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
Apache 为什么.htaccess受保护的目录可以在http上工作而不能在https上工作?_Apache_.htaccess_Ubuntu_Https - Fatal编程技术网

Apache 为什么.htaccess受保护的目录可以在http上工作而不能在https上工作?

Apache 为什么.htaccess受保护的目录可以在http上工作而不能在https上工作?,apache,.htaccess,ubuntu,https,Apache,.htaccess,Ubuntu,Https,我有一个域名example.comexample.com链接到Tumblr博客sub.example.com链接到我家Ubuntu服务器的Apache服务器。我还可以选择在sub.example.com中启用SSL(即,用户可以选择对任何网页使用http或https)sub.example.com/directory受.htaccess保护。我可以在http://sub.example.com/directory,但不在https://sub.example.com/directory。在htt

我有一个域名
example.com
example.com
链接到Tumblr博客
sub.example.com
链接到我家Ubuntu服务器的Apache服务器。我还可以选择在
sub.example.com
中启用SSL(即,用户可以选择对任何网页使用
http
https
sub.example.com/directory
受.htaccess保护。我可以在
http://sub.example.com/directory
,但不在
https://sub.example.com/directory
。在
https
版本中,系统会提示我输入登录信息。在中输入凭据后,出现以下错误:

错误:找不到文件
找不到文件。

我不确定出了什么问题。下面是完整的
/var/www/html/directory/.htaccess
文件和
/etc/apache2/apache2.conf
文件的选定部分

.htaccess:

AuthType Basic
AuthName "Password Protected Area"
AuthUserFile /var/www/.htpasswd
Require valid-user
apache2.conf:

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

选项索引跟随符号链接
允许超越所有
要求所有授权

我使用的是Ubuntu 14.10和Apache 2.4.10,请检查以下步骤

  • 确保您的HTTPS在没有密码的情况下工作
  • 确保.htaccess点指向正确的.htpasswd路径
  • 我认为您的apache2.conf很好,但是如果端口443有任何错误,请检查sites enabled和conf available中的配置文件

  • 就像计算机上的许多事情一样,重启修复了我的问题。所以,我可能没有重新启动一些服务

    HTTPS在受保护目录之外工作正常。使用HTTP时,可以使用密码访问该目录。由于HTTPS在
    sub.example.com
    上运行良好,SSL(大概)配置正确。