Server 路径中第一个目录在站点目录之前。

Server 路径中第一个目录在站点目录之前。,server,apache2,apache2.4,Server,Apache2,Apache2.4,问题可能是指令不在 该指令可以在、或节以及.htaccess文件中引用,以控制对服务器特定部分的访问。可以根据客户端主机名或IP地址控制访问。我还有一个可能对某人有用的。 从PHP 5.6=>7.0升级后收到相同的错误消息。我们已经更改了PHP上传设置,并且在复制后忘记了更改。 尽管当时我没有上传图像,但Silverstripe(我们的CMS)拒绝保存并抛出该错误。增加了图像上传的大小,它马上就能工作。使用Ubuntu时,请检查CGI模块是否已启用。如果没有: sudo a2enmod cgi

问题可能是指令不在


该指令可以在节以及.htaccess文件中引用,以控制对服务器特定部分的访问。可以根据客户端主机名或IP地址控制访问。

我还有一个可能对某人有用的。 从PHP 5.6=>7.0升级后收到相同的错误消息。我们已经更改了PHP上传设置,并且在复制后忘记了更改。
尽管当时我没有上传图像,但Silverstripe(我们的CMS)拒绝保存并抛出该错误。增加了图像上传的大小,它马上就能工作。

使用Ubuntu时,请检查CGI模块是否已启用。如果没有:

sudo a2enmod cgi
就我而言

我正在使用macOS Mojave(Apache/2.4.34)。/etc/apache2/extra/httpd-vhosts.conf文件中的虚拟主机设置存在问题。添加所需的目录标记后,我的问题消失了

要求所有授权

希望完整的虚拟主机安装结构将为您节省时间

<VirtualHost *:80>
    DocumentRoot "/Users/vagabond/Sites/MainProjectFolderName/public/"
    ServerName project.loc

    <Directory /Users/vagabond/Sites/MainProjectFolderName/public/>
        Require all granted
    </Directory>

    ErrorLog "/Users/vagabond/Sites/logs/MainProjectFolderName.loc-error_log"
    CustomLog "/Users/vagabond/Sites/logs/MainProjectFolderName.loc-access_log" common
</VirtualHost>

DocumentRoot“/Users/vagabond/Sites/MainProjectFolderName/public/”
ServerName project.loc
要求所有授权
ErrorLog“/Users/vagabond/Sites/logs/MainProjectFolderName.loc-error\u log”
CustomLog“/Users/vagabond/Sites/logs/MainProjectFolderName.loc-access\u log”通用
您只需将MainProjectFolderName替换为准确的ProjectFolderName即可。

确保包含任何特定于用户的配置! 如果这一页上的其他答案都不适合你的话,下面是我在几个小时的苦苦挣扎后遇到的问题

我使用了特定于用户的配置,在
/private/etc/apache2/extra/httpd UserDir.conf
中将
站点指定为我的
UserDir
。但是,我被禁止访问端点
http://localhost/~jwork/

我可以在
/var/log/apache2/error\u log
中看到对
/Users/jwork/Sites/
的访问被阻止。但是,我被允许通过
http://localhost/
。这表明我没有查看
~jwork
用户的权限。但是,据我所知,apache是为
jwork
用户运行的,所以我的用户配置显然没有写一些东西

给定一个名为
jwork
的用户,下面是我的配置文件:

/private/etc/apache2/users/jwork.conf
注意,这是userdir conf文件的默认路径,但正如您将在下面看到的,它可以在
httpd.conf
中配置。确保已启用以下行:

/private/etc/apache2/httpd.conf

对于那些以我的身份遇到这个错误而上面没有任何帮助的人:检查error.log中的问题文件夹是否确实存在于您的服务器上。Django在错误的位置自动生成了Mine(与static root混淆,然后
manage.py collectstatic
)。不知道为什么不能正确命名错误。

如果您在windows操作系统上的WampServer中使用Apache 2.4

您需要在记事本中打开https vhosts.conf文件

C:\wamp64\bin\apache\apache2.4.37\conf\extra\https-vhosts.conf 
如果您无法找到上述文件。查看下面的屏幕截图


并保存它。重新启动Apache服务并重试。

如果这有助于像我一样在谷歌上搜索的任何人,我在尝试访问服务器上的SVG文件时收到此错误消息,例如。其他文件类型似乎不错,只是SVG失败了

我搜索了
/etc/httpd
conf文件,检查了每种
require-all-denied
类型的配置,只是找不到哪个配置具有这种效果

我在VirtualHost配置中将LogLevel设置为debug,可以看到mod_authz_core日志指定存在有效的“Require all denied”:

[Mon Jun 10 13:09:54.321022 2019] [authz_core:debug] [pid 23459:tid 140576341206784] mod_authz_core.c(817): [client 127.0.0.1:54626] AH01626: authorization result of Require all denied: denied
[Mon Jun 10 13:09:54.321038 2019] [authz_core:debug] [pid 23459:tid 140576341206784] mod_authz_core.c(817): [client 127.0.0.1:54626] AH01626: authorization result of <RequireAny>: denied
[Mon Jun 10 13:09:54.321082 2019] [authz_core:error] [pid 23459:tid 140576341206784] [client 127.0.0.1:54626] AH01630: client denied by server configuration: /home/blah/htdocs/images/file.svg
[Mon Jun 10 13:09:54.321022 2019][authz_core:debug][pid 23459:tid 140576341206784]mod_authz_core.c(817):[client 127.0.0.1:54626]AH01626:拒绝所有请求的授权结果:拒绝
[Mon Jun 10 13:09:54.321038 2019][authz_core:debug][pid 23459:tid 140576341206784]mod_authz_core.c(817):[client 127.0.0.1:54626]AH01626:的授权结果:拒绝
[Mon Jun 10 13:09:54.321082 2019][authz_core:error][pid 23459:tid 140576341206784][client 127.0.0.1:54626]AH01630:客户端被服务器配置拒绝:/home/blah/htdocs/images/file.svg
通过盲测试,我将文件移动到web根目录的根目录下,然后发现我可以在。。因此,它只在“图像”文件夹中失败。这让我找到了images文件夹中的一个.htaccess文件,我不知道它在那里

Zen Cart 1.5附带了一个images/.htaccess文件,该文件具有:

# deny *everything*
 <FilesMatch ".*">
   <IfModule mod_authz_core.c>
     Require all denied
   </IfModule>
   <IfModule !mod_authz_core.c>
     Order Allow,Deny
     Deny from all
   </IfModule>
 </FilesMatch>

 # but now allow just *certain* necessary files:
 <FilesMatch "(?i).*\.(jpe?g|gif|webp|png|swf)$" >
   <IfModule mod_authz_core.c>
     Require all granted
   </IfModule>
   <IfModule !mod_authz_core.c>
     Order Allow,Deny
     Allow from all
   </IfModule>
 </FilesMatch>
#拒绝*一切*
要求全部拒绝
命令允许,拒绝
全盘否定
#但现在只允许*某些*必要的文件:
要求所有授权
命令允许,拒绝
通融

这很烦人,我希望这可能会提醒其他人检查文件系统的各个级别上的.htaccess文件,以防出现这种tom的愚蠢行为。实际上,我通过将目录访问添加到:80条目中解决了这个问题

 <Directory "c:/whatever-directory-you-use/">
    AllowOverride All
    Require all granted
</Directory>

允许超越所有
要求所有授权
在每个人都对我有“安全感”之前,在我的特定情况下,这不是安全问题


如果您使用的是远程资源,我建议您改为确保您的CURL请求通过HTTPS/TLS,然后此目录条目位于443端口。

对于我来说,我实际上已经根据2.4标准更新了允许和拒绝规则

Require all granted
但是,这仍然导致我收到相同的AH01630错误。我找到了另一根线,它
<Directory />
    AllowOverride none
    Require all denied
</Directory>

<Directory /Volumes/Data/Data/USER/Sites/>
    AllowOverride none
    Require all granted
</Directory>
 conf
  # Virtual hosts
  Include conf/extra/httpd-vhosts.conf
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# ps -eFH | grep http # get the username used by httpd
...
apache   18837  2692  0 119996 9328   9 10:33 ?        00:00:00     /usr/sbin/httpd -DFOREGROUND
# su -s/bin/bash apache # switch to that user
bash-4.2$ whoami
apache
bash-4.2$ cd /home
bash-4.2$ ls
bash-4.2$ cd mysite.com
bash-4.2$ ls
bash-4.2$ cat file-which-does-not-work.txt
Require local
Require all granted
Include conf/extra/httpd-vhosts.conf
<DirectoryMatch "/home/user-[a-z]+/www/myproject/">
...
</DirectoryMatch>
RewriteRule /some_image.png /media/some_other_location.png
sudo a2enmod cgi
<VirtualHost *:80>
    DocumentRoot "/Users/vagabond/Sites/MainProjectFolderName/public/"
    ServerName project.loc

    <Directory /Users/vagabond/Sites/MainProjectFolderName/public/>
        Require all granted
    </Directory>

    ErrorLog "/Users/vagabond/Sites/logs/MainProjectFolderName.loc-error_log"
    CustomLog "/Users/vagabond/Sites/logs/MainProjectFolderName.loc-access_log" common
</VirtualHost>
<Directory "/Users/jwork/Sites/">
    Require all granted
</Directory>
## Note how it's commented out by default.
## Just remove the comment to enable your user conf.
#Include /private/etc/apache2/users/*.conf
Include /private/etc/apache2/extra/httpd-userdir.conf

# ...

LoadModule userdir_module libexec/apache2/mod_userdir.so
C:\wamp64\bin\apache\apache2.4.37\conf\extra\https-vhosts.conf 
 <VirtualHost *:80>
     ServerName localhost
     DocumentRoot c:/wamp64/www
     <Directory  "c:/wamp64/www/">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>
Require local
Require all granted
[Mon Jun 10 13:09:54.321022 2019] [authz_core:debug] [pid 23459:tid 140576341206784] mod_authz_core.c(817): [client 127.0.0.1:54626] AH01626: authorization result of Require all denied: denied
[Mon Jun 10 13:09:54.321038 2019] [authz_core:debug] [pid 23459:tid 140576341206784] mod_authz_core.c(817): [client 127.0.0.1:54626] AH01626: authorization result of <RequireAny>: denied
[Mon Jun 10 13:09:54.321082 2019] [authz_core:error] [pid 23459:tid 140576341206784] [client 127.0.0.1:54626] AH01630: client denied by server configuration: /home/blah/htdocs/images/file.svg
# deny *everything*
 <FilesMatch ".*">
   <IfModule mod_authz_core.c>
     Require all denied
   </IfModule>
   <IfModule !mod_authz_core.c>
     Order Allow,Deny
     Deny from all
   </IfModule>
 </FilesMatch>

 # but now allow just *certain* necessary files:
 <FilesMatch "(?i).*\.(jpe?g|gif|webp|png|swf)$" >
   <IfModule mod_authz_core.c>
     Require all granted
   </IfModule>
   <IfModule !mod_authz_core.c>
     Order Allow,Deny
     Allow from all
   </IfModule>
 </FilesMatch>
 <Directory "c:/whatever-directory-you-use/">
    AllowOverride All
    Require all granted
</Directory>
Require all granted
<Location />
require all granted
</Location>