Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have the following virtual host on my development server:

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

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.

share|improve this question

migrated from webmasters.stackexchange.com Jan 31 '11 at 12:53

This question came from our site for pro webmasters.

    
If I'm not mistaken, mod_rewrite has nothing to do with physical directories, matched by <Directory>. So if you're rewriting /public/file.html to a file outside /srv/web/example.com/pub, it will work. –  Lekensteyn Jan 31 '11 at 12:59
add comment

3 Answers

I think you can put something like this before (but maybe after) the <Directory> block.

<LocationMatch "^/public/file.html">
 Satisfy Any
 Allow from all
</LocationMatch>

I am not 100% sure about the order of operations when looking at permissions.

share|improve this answer
add comment

I think you could do something like this: (not tested)

<Location /public/file.html>
  Order Deny,Allow
  Allow from All
  (Your mod_rewrite stuff)
</Location>
share|improve this answer
add comment
up vote 0 down vote accepted

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>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.