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 an Apache config that restricts access to to a website, using the following code -

<Directory /var/www/html/website/test/>
        AuthName "Dyne Drewett Test Site"
        AuthType Basic
        AuthUserFile /usr/local/etc/apache/.htpasswd
        require valid-user
</Directory>

Does anybody know how I can amend this to allow full, unauthorised access to one directory under /test/? Thanks.

Update

After some help from @dunxd I now have this, which I'm guessing must be wrong as I'm still getting the 401 error when going to the page that is requested (found with the /dyne_drewett/ directory). Any further help would be great.

# Main directory rules
<Directory /var/www/html/website/test/>

    # General access to the site
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from 192.168.1

    # Authorisation settings
        AuthName "Dyne Drewett Test Site"
        AuthType Basic
        AuthUserFile /usr/local/etc/apache/.htpasswd
        require valid-user

</Directory>

# Theme directory rules
<Directory /var/www/html/website/test/wp-content/themes/dyne_drewett/>

    # General access to the folder
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all

    # Authorisation settings
        AuthType None
        require all granted

</Directory>
share|improve this question
add comment

1 Answer

There are a couple of ways of achieving this.

Simplest way is to create another Directory entry for the subdirectory with AuthType set to None like this:

<Directory /test/public>
AuthType None
Require all granted
</Directory>

Another approach uses a different URL pointing to the directory. In Apache docs for Directory directive there is a comment saying:

Be careful with the directory-path arguments: They have to literally match the filesystem path which Apache httpd uses to access the files. Directives applied to a particular will not apply to files accessed from that same directory via a different path, such as via different symbolic links.

You could use that to your advantage here - create a symlink from /allowed/ to your subdirectory under /test/ and use that URL to point to the directory.

share|improve this answer
    
Thanks for the help. I've updated my question with all <directory> entries from my config, as I still can't get it to work. I'd be grateful if you could take a look and let me know if anything looks incorrect. Thanks. –  David Gard Mar 13 '12 at 15:41
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.