Apache 只有192.168.0.3可以请求,但任何人都可以请求/public/file.html
我的开发服务器上有以下虚拟主机:Apache 只有192.168.0.3可以请求,但任何人都可以请求/public/file.html,apache,networking,apache2,request,Apache,Networking,Apache2,Request,我的开发服务器上有以下虚拟主机: <VirtualHost *:80> ServerName example.com DocumentRoot /srv/web/example.com/pub <Directory /srv/web/example.com/pub> Order Deny,Allow Deny from all Allow from 192.168.0.3 </Direc
<VirtualHost *:80>
ServerName example.com
DocumentRoot /srv/web/example.com/pub
<Directory /srv/web/example.com/pub>
Order Deny,Allow
Deny from all
Allow from 192.168.0.3
</Directory>
</VirtualHost>
如何更改此设置以允许任何人通过/public/file.html
请求
注意:
/public/file.html
实际上并不作为文件存在于服务器上。我使用mod_rewrite
通过单个索引文件重定向所有传入请求要将配置指令应用于未映射到文件系统的路径,必须使用封闭指令:
<Location /public/file.html>
Order Deny,Allow
Allow From All
</Location>
命令拒绝,允许
通融
这是我找到的唯一解决方法:
<VirtualHost *:80>
ServerName example.com
DocumentRoot /srv/web/example.com/pub
SetEnvIf Request_URI "/public/file.html" public
<Directory /srv/web/example.com/pub>
Order Deny,Allow
Deny from all
Allow from 192.168.0.3
Allow from env=public
</Directory>
</VirtualHost>
ServerName example.com
DocumentRoot/srv/web/example.com/pub
SetEnvIf Request_URI“/public/file.html”public
命令拒绝,允许
全盘否定
允许从192.168.0.3开始
允许来自env=公共
属于每次我将任何内容发布到webmasters.stackexchange.com时,它都会被迁移到服务器故障。
<VirtualHost *:80>
ServerName example.com
DocumentRoot /srv/web/example.com/pub
SetEnvIf Request_URI "/public/file.html" public
<Directory /srv/web/example.com/pub>
Order Deny,Allow
Deny from all
Allow from 192.168.0.3
Allow from env=public
</Directory>
</VirtualHost>