开发者

Only 192.168.0.3 can request, but anyone can request /public/file.html

I have the following virtual host on my development server:

<VirtualHost *:80>
    ServerName exa开发者_运维百科mple.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>

The Allow from 192.168.0.3 part is to only allow requests from my workstation machine.

I want to tweak this to allow anyone to request a certain URL:

http://example.com/public/file.html

How do I change this to allow /public/file.html requests to get through from anyone?

Note: /public/file.html doesn't actually exist as a file on the server. I redirect all incoming requests through a single index file using mod_rewrite.


To apply configuration directives to paths that do not map to the filesystem, you must use the Location enclosing directive:

<Location /public/file.html>
    Order Deny,Allow
    Allow From All
</Location>


This is only way that I found to fix it:

<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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜